From 0c806305779b7431e5adf1766d4867d3369392a7 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Mon, 17 Sep 2018 22:27:43 +0000 Subject: [PATCH] [vm] Fix ia32/x64 gcc build. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (The simulators are broken at runtime.) Change-Id: I10089cad44fca57145cfdd598342279f07c6d7fd Reviewed-on: https://dart-review.googlesource.com/75205 Reviewed-by: RĂ©gis Crelier Reviewed-by: Zach Anderson Commit-Queue: Ryan Macnak --- build/config/compiler/BUILD.gn | 6 ++++-- runtime/BUILD.gn | 1 + runtime/bin/options.h | 20 ++++++++++++++++++- runtime/vm/compiler/backend/il_arm64.cc | 1 - .../frontend/kernel_binary_flowgraph.cc | 1 + runtime/vm/exceptions.cc | 5 ++++- runtime/vm/interpreter.cc | 18 +++++++++-------- runtime/vm/simulator_arm.cc | 3 ++- 8 files changed, 41 insertions(+), 14 deletions(-) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index e29aa03d2b8..4e9d66b1585 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -690,11 +690,13 @@ if (is_win) { # See http://lwn.net/Articles/192624/ . "-Wl,-O1", "-Wl,--gc-sections", + ] + if (is_clang) { # Identical code folding to reduce size. # Warning: This changes C/C++ semantics of function pointer comparison. - "-Wl,--icf=all", - ] + common_optimize_on_ldflags += [ "-Wl,--icf=all" ] + } if (!using_sanitizer) { # Functions interposed by the sanitizers can make ld think diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index bc08e005e79..865e716b520 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -158,6 +158,7 @@ config("dart_config") { "-Wvla", "-Wno-conversion-null", "-Woverloaded-virtual", + "-Wno-comments", # Conflicts with clang-format. "-g3", "-ggdb3", "-fno-rtti", diff --git a/runtime/bin/options.h b/runtime/bin/options.h index e4edbcfbc69..336d934918b 100644 --- a/runtime/bin/options.h +++ b/runtime/bin/options.h @@ -119,7 +119,25 @@ class CallbackOptionProcessor : public OptionProcessor { static OptionProcessor_##name option_##name; #define DEFINE_BOOL_OPTION(name, variable) \ - DEFINE_BOOL_OPTION_CB(name, { variable = true; }) + class OptionProcessor_##name : public OptionProcessor { \ + public: \ + virtual bool Process(const char* option, CommandLineOptions* vm_options) { \ + const char* value = OptionProcessor::ProcessOption(option, "--" #name); \ + if (value == NULL) { \ + return false; \ + } \ + if (*value == '=') { \ + Log::PrintErr("Non-empty value for option " #name "\n"); \ + return false; \ + } \ + if (*value != '\0') { \ + return false; \ + } \ + variable = true; \ + return true; \ + } \ + }; \ + static OptionProcessor_##name option_##name; #define DEFINE_BOOL_OPTION_SHORT(short_name, long_name, variable) \ class OptionProcessor_##long_name : public OptionProcessor { \ diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc index 61b4766153d..41fcd15fbfb 100644 --- a/runtime/vm/compiler/backend/il_arm64.cc +++ b/runtime/vm/compiler/backend/il_arm64.cc @@ -1141,7 +1141,6 @@ void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { (representation() == kUnboxedFloat64x2)) { const VRegister result = locs()->out(0).fpu_reg(); switch (class_id()) { - ASSERT(aligned()); case kTypedDataFloat32ArrayCid: // Load single precision float. if (aligned()) { diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc index 4392efd05e0..e8b948c7ee1 100644 --- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc +++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc @@ -1190,6 +1190,7 @@ FlowGraph* StreamingFlowGraphBuilder::BuildGraphOfDynamicInvocationForwarder() { first_parameter_offset = ReaderOffset() + data_program_offset_; } } + USE(first_parameter_offset); // Current position: About to read list of positionals. // Should never build a dynamic invocation forwarder for equality diff --git a/runtime/vm/exceptions.cc b/runtime/vm/exceptions.cc index 52487822de3..45d836a85c1 100644 --- a/runtime/vm/exceptions.cc +++ b/runtime/vm/exceptions.cc @@ -283,6 +283,9 @@ class ExceptionHandlerFinder : public StackResource { case CatchEntryMove::SourceKind::kUint32Slot: value = Integer::New(*SlotAt(fp, move.src_slot())); break; + + default: + UNREACHABLE(); } *TaggedSlotAt(fp, move.dest_slot()) = value; @@ -296,7 +299,7 @@ class ExceptionHandlerFinder : public StackResource { NoSafepointScope no_safepoint; ReadStream stream(static_cast(td.DataAddr(0)), td.Length()); - intptr_t prefix_length, suffix_length, suffix_offset; + intptr_t prefix_length = 0, suffix_length = 0, suffix_offset = 0; while (stream.PendingBytes() > 0) { intptr_t target_pc_offset = Reader::Read(&stream); prefix_length = Reader::Read(&stream); diff --git a/runtime/vm/interpreter.cc b/runtime/vm/interpreter.cc index 62a2fd57fa0..96509570181 100644 --- a/runtime/vm/interpreter.cc +++ b/runtime/vm/interpreter.cc @@ -890,7 +890,7 @@ DART_NOINLINE bool Interpreter::InvokeCompiled(Thread* thread, UNIMPLEMENTED(); #endif ASSERT(Function::HasCode(function)); - RawCode* code = function->ptr()->code_; + RawCode* volatile code = function->ptr()->code_; ASSERT(code != StubCode::LazyCompile_entry()->code()); // TODO(regis): Once we share the same stack, try to invoke directly. #if defined(DEBUG) @@ -902,9 +902,9 @@ DART_NOINLINE bool Interpreter::InvokeCompiled(Thread* thread, // On success, returns a RawInstance. On failure, a RawError. typedef RawObject* (*invokestub)(RawCode * code, RawArray * argdesc, RawObject * *arg0, Thread * thread); - invokestub entrypoint = reinterpret_cast( + invokestub volatile entrypoint = reinterpret_cast( StubCode::InvokeDartCodeFromBytecode_entry()->EntryPoint()); - RawObject* result; + RawObject* volatile result; Exit(thread, *FP, call_top + 1, *pc); { InterpreterSetjmpBuffer buffer(this); @@ -969,11 +969,13 @@ DART_NOINLINE bool Interpreter::ProcessInvocation(bool* invoked, RawField* field = reinterpret_cast(function->ptr()->data_); intptr_t offset_in_words = Smi::Value(field->ptr()->value_.offset_); RawAbstractType* field_type = field->ptr()->type_; - const classid_t cid = - field_type->GetClassId() == kTypeCid - ? Smi::Value(reinterpret_cast( - Type::RawCast(field_type)->ptr()->type_class_id_)) - : kIllegalCid; // Not really illegal, but not a Type to skip. + classid_t cid; + if (field_type->GetClassId() == kTypeCid) { + cid = Smi::Value(reinterpret_cast( + Type::RawCast(field_type)->ptr()->type_class_id_)); + } else { + cid = kIllegalCid; // Not really illegal, but not a Type to skip. + } // Perform type test of value if field type is not one of dynamic, object, // or void, and if the value is not null. RawObject* null_value = Object::null(); diff --git a/runtime/vm/simulator_arm.cc b/runtime/vm/simulator_arm.cc index 8951295d6d1..db660f8ec95 100644 --- a/runtime/vm/simulator_arm.cc +++ b/runtime/vm/simulator_arm.cc @@ -1592,8 +1592,8 @@ DART_FORCE_INLINE void Simulator::DecodeType01(Instr* instr) { // Registers rd, rn, rm, ra are encoded as rn, rm, rs, rd. // Format(instr, "mls'cond's 'rn, 'rm, 'rs, 'rd"); rd_val = get_register(rd); - // fall through } + /* Falls through */ case 0: { // Registers rd, rn, rm are encoded as rn, rm, rs. // Format(instr, "mul'cond's 'rn, 'rm, 'rs"); @@ -1650,6 +1650,7 @@ DART_FORCE_INLINE void Simulator::DecodeType01(Instr* instr) { // umaal is only in ARMv6 and above. UnimplementedInstruction(instr); } + /* Falls through */ case 5: // Registers rd_lo, rd_hi, rn, rm are encoded as rd, rn, rm, rs. // Format(instr, "umlal'cond's 'rd, 'rn, 'rm, 'rs");