Index: runtime/vm/flow_graph_compiler_ia32.cc |
=================================================================== |
--- runtime/vm/flow_graph_compiler_ia32.cc (revision 28803) |
+++ runtime/vm/flow_graph_compiler_ia32.cc (working copy) |
@@ -8,6 +8,7 @@ |
#include "vm/flow_graph_compiler.h" |
#include "vm/ast_printer.h" |
+#include "vm/compiler.h" |
#include "vm/dart_entry.h" |
#include "vm/deopt_instructions.h" |
#include "vm/il_printer.h" |
@@ -1098,6 +1099,31 @@ |
ASSERT(StackSize() >= 0); |
__ EnterDartFrame(StackSize() * kWordSize); |
} |
+ |
+ // TODO(zra): maybe do this only before we try to optimize? |
+ if (FLAG_collect_code) { |
+ // If we are collecting code, make sure this function still has a pointer |
+ // to the code object. |
+ // TODO(zra): Is it cheaper just to write the Function fields with the |
+ // code object without doing the test? |
+ Label is_connected; |
+ const Immediate& raw_null = |
+ Immediate(reinterpret_cast<intptr_t>(Object::null())); |
+ const Register function_reg = EDI; |
+ __ LoadObject(function_reg, function); |
+ __ movl(EAX, FieldAddress(function_reg, Function::code_offset())); |
+ __ cmpl(EAX, raw_null); |
+ __ j(NOT_EQUAL, &is_connected, Assembler::kNearJump); |
srdjan
2013/10/18 17:16:07
Add comment what you are doing: add the code objec
zra
2013/10/22 16:13:24
Code obsolete.
|
+ __ movl(EAX, Address(EBP, kPcMarkerSlotFromFp * kWordSize)); |
+ const intptr_t code_pc_dist = |
+ Instructions::HeaderSize() - Instructions::code_offset() + |
+ Assembler::kEntryPointToPcMarkerOffset; |
srdjan
2013/10/18 17:16:07
Indent 4 chars the two lines above
zra
2013/10/22 16:13:24
Code obsolete
|
+ __ movl(EAX, Address(EAX, -code_pc_dist)); |
+ __ movl(FieldAddress(function_reg, Function::code_offset()), EAX); |
+ __ movl( |
+ FieldAddress(function_reg, Function::unoptimized_code_offset()), EAX); |
+ __ Bind(&is_connected); |
+ } |
} |
@@ -1412,8 +1438,27 @@ |
// illegal class id was found, the target is a cache miss handler that can |
// be invoked as a normal Dart function. |
__ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize)); |
- __ movl(EAX, FieldAddress(EAX, Function::code_offset())); |
- __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); |
+ __ movl(EBX, FieldAddress(EAX, Function::code_offset())); |
+ if (FLAG_collect_code) { |
+ // If we are collecting code, the code object may be null. |
+ Label is_compiled; |
+ const Immediate& raw_null = |
+ Immediate(reinterpret_cast<intptr_t>(Object::null())); |
+ __ cmpl(EBX, raw_null); |
+ __ j(NOT_EQUAL, &is_compiled, Assembler::kNearJump); |
+ __ EnterStubFrame(); |
+ __ pushl(EDX); // Preserve arguments descriptor array. |
+ __ pushl(ECX); // Preserve IC data object. |
+ __ pushl(EAX); // Pass function. |
+ __ CallRuntime(kCompileFunctionRuntimeEntry, 1); |
+ __ popl(EAX); // Restore function. |
srdjan
2013/10/18 17:16:07
The argument can be modified in the callee, theref
zra
2013/10/22 16:13:24
At other call-sites of CompileFunction (e.g. aroun
|
+ __ popl(ECX); // Restore IC data array. |
+ __ popl(EDX); // Restore arguments descriptor array. |
+ __ LeaveFrame(); |
+ __ movl(EBX, FieldAddress(EAX, Function::code_offset())); |
+ __ Bind(&is_compiled); |
+ } |
+ __ movl(EAX, FieldAddress(EBX, Code::instructions_offset())); |
__ LoadObject(ECX, ic_data); |
__ LoadObject(EDX, arguments_descriptor); |
__ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |