Index: src/ia32/stub-cache-ia32.cc |
=================================================================== |
--- src/ia32/stub-cache-ia32.cc (revision 2285) |
+++ src/ia32/stub-cache-ia32.cc (working copy) |
@@ -627,6 +627,7 @@ |
__ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
// Jump to the cached code (tail call). |
+ ASSERT(function->is_compiled()); |
Handle<Code> code(function->code()); |
ParameterCount expected(function->shared()->formal_parameter_count()); |
__ InvokeCode(code, expected, arguments(), |
@@ -718,6 +719,59 @@ |
} |
+Object* CallStubCompiler::CompileCallGlobal(JSGlobalObject* object, |
+ JSGlobalPropertyCell* cell, |
+ JSFunction* function, |
+ String* name) { |
+ // ----------- S t a t e ------------- |
+ // ----------------------------------- |
+ Label miss; |
+ |
+ __ IncrementCounter(&Counters::call_global_inline, 1); |
+ |
+ // Get the number of arguments. |
+ const int argc = arguments().immediate(); |
+ |
+ // Check that the map of the global has not changed. |
+ __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
+ __ cmp(FieldOperand(edx, HeapObject::kMapOffset), |
+ Immediate(Handle<Map>(object->map()))); |
+ __ j(not_equal, &miss, not_taken); |
+ |
+ // Get the value from the cell. |
+ __ mov(edi, Immediate(Handle<JSGlobalPropertyCell>(cell))); |
+ __ mov(edi, FieldOperand(edi, JSGlobalPropertyCell::kValueOffset)); |
+ |
+ // Check that the cell contains the same function. |
+ __ cmp(Operand(edi), Immediate(Handle<JSFunction>(function))); |
+ __ j(not_equal, &miss, not_taken); |
+ |
+ // Patch the receiver on the stack with the global proxy. |
+ __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); |
+ __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); |
+ |
+ // Setup the context (function already in edi). |
+ __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
+ |
+ // Jump to the cached code (tail call). |
+ ASSERT(function->is_compiled()); |
+ Handle<Code> code(function->code()); |
+ ParameterCount expected(function->shared()->formal_parameter_count()); |
+ __ InvokeCode(code, expected, arguments(), |
+ RelocInfo::CODE_TARGET, JUMP_FUNCTION); |
+ |
+ // Handle call cache miss. |
+ __ bind(&miss); |
+ __ DecrementCounter(&Counters::call_global_inline, 1); |
+ __ IncrementCounter(&Counters::call_global_inline_miss, 1); |
+ Handle<Code> ic = ComputeCallMiss(arguments().immediate()); |
+ __ jmp(ic, RelocInfo::CODE_TARGET); |
+ |
+ // Return the generated code. |
+ return GetCode(NORMAL, name); |
+} |
+ |
+ |
Object* StoreStubCompiler::CompileStoreField(JSObject* object, |
int index, |
Map* transition, |
@@ -861,6 +915,49 @@ |
} |
+Object* StoreStubCompiler::CompileStoreGlobal(JSGlobalObject* object, |
+ JSGlobalPropertyCell* cell, |
+ String* name) { |
+ // ----------- S t a t e ------------- |
+ // -- eax : value |
+ // -- ecx : name |
+ // -- esp[0] : return address |
+ // -- esp[4] : receiver |
+ // ----------------------------------- |
+ Label miss; |
+ |
+ __ IncrementCounter(&Counters::named_store_global_inline, 1); |
+ |
+ // Check that the map of the global has not changed. |
+ __ mov(ebx, (Operand(esp, kPointerSize))); |
+ __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), |
+ Immediate(Handle<Map>(object->map()))); |
+ __ j(not_equal, &miss, not_taken); |
+ |
+ // Store the value in the cell. |
+ __ mov(ecx, Immediate(Handle<JSGlobalPropertyCell>(cell))); |
+ __ mov(FieldOperand(ecx, JSGlobalPropertyCell::kValueOffset), eax); |
+ |
+ // RecordWrite clobbers the value register. Pass the value being stored in |
+ // edx. |
+ __ mov(edx, eax); |
+ __ RecordWrite(ecx, JSGlobalPropertyCell::kValueOffset, edx, ebx); |
+ |
+ // Return the value (register eax). |
+ __ ret(0); |
+ |
+ // Handle store cache miss. |
+ __ bind(&miss); |
+ __ DecrementCounter(&Counters::named_store_global_inline, 1); |
+ __ IncrementCounter(&Counters::named_store_global_inline_miss, 1); |
+ Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss)); |
+ __ jmp(ic, RelocInfo::CODE_TARGET); |
+ |
+ // Return the generated code. |
+ return GetCode(NORMAL, name); |
+} |
+ |
+ |
Object* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, |
int index, |
Map* transition, |
@@ -999,6 +1096,44 @@ |
} |
+Object* LoadStubCompiler::CompileLoadGlobal(JSGlobalObject* object, |
+ JSGlobalPropertyCell* cell, |
+ String* name) { |
+ // ----------- S t a t e ------------- |
+ // -- ecx : name |
+ // -- esp[0] : return address |
+ // -- esp[4] : receiver |
+ // ----------------------------------- |
+ Label miss; |
+ |
+ __ IncrementCounter(&Counters::named_load_global_inline, 1); |
+ |
+ // Check that the map of the global has not changed. |
+ __ mov(eax, (Operand(esp, kPointerSize))); |
+ __ cmp(FieldOperand(eax, HeapObject::kMapOffset), |
+ Immediate(Handle<Map>(object->map()))); |
+ __ j(not_equal, &miss, not_taken); |
+ |
+ // Get the value from the cell. |
+ __ mov(eax, Immediate(Handle<JSGlobalPropertyCell>(cell))); |
+ __ mov(eax, FieldOperand(eax, JSGlobalPropertyCell::kValueOffset)); |
+ |
+ // Check for deleted property. |
+ __ cmp(eax, Factory::the_hole_value()); |
+ __ j(equal, &miss, not_taken); |
+ |
+ __ ret(0); |
+ |
+ __ bind(&miss); |
+ __ DecrementCounter(&Counters::named_load_global_inline, 1); |
+ __ IncrementCounter(&Counters::named_load_global_inline_miss, 1); |
+ GenerateLoadMiss(masm(), Code::LOAD_IC); |
+ |
+ // Return the generated code. |
+ return GetCode(NORMAL, name); |
+} |
+ |
+ |
Object* KeyedLoadStubCompiler::CompileLoadField(String* name, |
JSObject* receiver, |
JSObject* holder, |