From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12878 invoked by alias); 4 Sep 2017 10:25:47 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 12859 invoked by uid 89); 4 Sep 2017 10:25:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=0033, b200, b300, Consumer X-HELO: mail-vk0-f52.google.com Received: from mail-vk0-f52.google.com (HELO mail-vk0-f52.google.com) (209.85.213.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Sep 2017 10:25:40 +0000 Received: by mail-vk0-f52.google.com with SMTP id o22so204279vke.1 for ; Mon, 04 Sep 2017 03:25:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=YlPQ+7QjhUc9Qq4B4Pp/YgLNUSupHjD+b8SokifYpLQ=; b=BSC/5VX8LyhBZjqzlUFiC6iP/ngPlDUXkfCd7dGCUbFy+WX5qA9AJSrmnbnmopUc0s W3gowHWViRPloTH8Bc44tpsHS1kzrxesF0Gj3OS89t0rtPTyYMf1W8AiGFbTCsuoTMBH 5AFmoeljy/3PfM1z+4LwIowhNQtIa82KVvwUeaIxeiwdGd3ieE8qo877KUn1bdOQWl29 h8I/m8Bv5T+0eaUm2dFj4tRtf4Ql+UHS9Kepfk+wEy08szcxOpR8qCxOjqYmlCH9ZwJs NhSWIyGMvYlXMvgkKZILJFpZeTVmD1IYTf0cc6VmFzSGDjrmx+FrXn4/JxdbCzzyLeMl ofkw== X-Gm-Message-State: AHPjjUh1A3Pi9NQogIbk7iTzbpXRHDHaF0j74VT0oJ61pfPSdQpi0Tvj 6D1OsjJICfpeMrPqNcx7G10llrBmN5n8 X-Google-Smtp-Source: ADKCNb4PJAW0CqkgdgZLVQwVbHJ9bzgpBIIEPbTf1p1sx5L9cFc+8sA9P7j+x8Rlnc//HHum2H4sTO/a6cZeIkUKx4Q= X-Received: by 10.31.50.69 with SMTP id y66mr5961600vky.134.1504520739142; Mon, 04 Sep 2017 03:25:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.49.231 with HTTP; Mon, 4 Sep 2017 03:25:38 -0700 (PDT) From: Kay Zheng Date: Mon, 04 Sep 2017 10:25:00 -0000 Message-ID: Subject: The "--no-inline" option caused Kawa to generate invalid bytecode To: Per Bothner , Kawa mailing list Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00031.txt.bz2 Hi Per, I think I hit a bug regarding "(define-early-constant ...)" and the "--no-inline" option. This is the problematic program: (define-library (kawa-test) (import (kawa base) (class java.lang System)) (export Main) (begin (define-early-constant MSG :: string (string-append "This" "is" "a" "dummy" "log")) (define-simple-class Main () ((main (args :: String[])) :: void allocation: 'class (invoke System:out 'println MSG))))) Save it as kawa-test.scm, and compile it with kawa --no-inline -C kawa-test.scm Then try to run the main method: java -cp .:kawa.jar Main The program will fail with this error message: Exception in thread "main" java.lang.VerifyError: Bad local variable type Exception Details: Location: kawa-test.()V @50: aload_0 Reason: Type top (current frame, locals[0]) is not assignable to reference type Current Frame: bci: @50 flags: { } locals: { } stack: { } Bytecode: 0x0000000: 124d b800 53b3 0033 1255 b800 53b3 002c 0x0000010: 1257 b800 53b3 0029 1259 b800 53b3 0026 0x0000020: 125b b800 53b3 0023 bb00 0259 b700 15b3 0x0000030: 0019 2ab2 001f b200 23b2 0026 b200 29b2 0x0000040: 002c b600 302a b200 33b6 0036 2ab6 003a 0x0000050: 123c b800 42c0 003c b300 4612 48b3 004b 0x0000060: b1 at Main.main(kawa-test.scm:13) I then disassembled kawa-test.class (the result is appended at the end of this email), and found that there was a "aload_0" instruction in the static initialization block. I'm not familiar with the JVM, but search results said the instruction was to read the argument array, yet there was no argument list for the static initialization block at all. Regards, Kay Z. ========= Disassembled kawa-test.class starts here ========= Compiled from "kawa-test.scm" public class kawa-test extends gnu.expr.ModuleBody implements java.lang.Runnable,gnu.expr.RunnableModule { public static final java.lang.Class Main; static final java.lang.CharSequence MSG; public static kawa-test $instance; static final gnu.lists.IString Lit0; static final gnu.lists.IString Lit1; static final gnu.lists.IString Lit2; static final gnu.lists.IString Lit3; static final gnu.lists.IString Lit4; public final void run(gnu.mapping.CallContext); Code: 0: aload_1 1: getfield #8 // Field gnu/mapping/CallContext.consumer:Lgnu/lists/Consumer; 4: astore_2 5: return public static {}; Code: 0: ldc #77 // String log 2: invokestatic #83 // Method gnu/lists/IString.valueOf:(Ljava/lang/CharSequence;)Lgnu/lists/IString; 5: putstatic #51 // Field Lit4:Lgnu/lists/IString; 8: ldc #85 // String dummy 10: invokestatic #83 // Method gnu/lists/IString.valueOf:(Ljava/lang/CharSequence;)Lgnu/lists/IString; 13: putstatic #44 // Field Lit3:Lgnu/lists/IString; 16: ldc #87 // String a 18: invokestatic #83 // Method gnu/lists/IString.valueOf:(Ljava/lang/CharSequence;)Lgnu/lists/IString; 21: putstatic #41 // Field Lit2:Lgnu/lists/IString; 24: ldc #89 // String is 26: invokestatic #83 // Method gnu/lists/IString.valueOf:(Ljava/lang/CharSequence;)Lgnu/lists/IString; 29: putstatic #38 // Field Lit1:Lgnu/lists/IString; 32: ldc #91 // String This 34: invokestatic #83 // Method gnu/lists/IString.valueOf:(Ljava/lang/CharSequence;)Lgnu/lists/IString; 37: putstatic #35 // Field Lit0:Lgnu/lists/IString; 40: new #2 // class "kawa-test" 43: dup 44: invokespecial #21 // Method "":()V 47: putstatic #25 // Field $instance:Lkawa-test; 50: aload_0 51: getstatic #31 // Field kawa/lib/kawa/istrings."string-append":Lgnu/expr/CompiledProc; 54: getstatic #35 // Field Lit0:Lgnu/lists/IString; 57: getstatic #38 // Field Lit1:Lgnu/lists/IString; 60: getstatic #41 // Field Lit2:Lgnu/lists/IString; 63: getstatic #44 // Field Lit3:Lgnu/lists/IString; 66: invokevirtual #48 // Method gnu/mapping/CallContext.setupApply:(Lgnu/mapping/Procedure;Ljava/lang/Object;Ljava/ 69: aload_0 70: getstatic #51 // Field Lit4:Lgnu/lists/IString; 73: invokevirtual #54 // Method gnu/mapping/CallContext.addArg:(Ljava/lang/Object;)V 76: aload_0 77: invokevirtual #58 // Method gnu/mapping/CallContext.runUntilValue:()Ljava/lang/Object; 80: ldc #60 // class java/lang/CharSequence 82: invokestatic #66 // Method gnu/mapping/Promise.force:(Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object; 85: checkcast #60 // class java/lang/CharSequence 88: putstatic #70 // Field MSG:Ljava/lang/CharSequence; 91: ldc #72 // class Main 93: putstatic #75 // Field Main:Ljava/lang/Class; 96: return public kawa-test(); Code: 0: aload_0 1: invokespecial #14 // Method gnu/expr/ModuleBody."":()V 4: aload_0 5: invokestatic #20 // Method gnu/expr/ModuleInfo.register:(Ljava/lang/Object;)V 8: return } ========= Disassembled kawa-test.class ends here =========