From 72ac6f619addbba8671f97e9a300e0f773e6ac47 Mon Sep 17 00:00:00 2001 From: "whesse@chromium.org" Date: Mon, 27 Jul 2009 15:02:35 +0000 Subject: [PATCH] X64: Add inline cache stub for storing to globals. Review URL: http://codereview.chromium.org/160160 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2543 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x64/stub-cache-x64.cc | 32 ++++++++++++++++++++++++++++++-- test/mjsunit/mjsunit.status | 2 +- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc index 32cbb98..af8d45a 100644 --- a/src/x64/stub-cache-x64.cc +++ b/src/x64/stub-cache-x64.cc @@ -471,8 +471,36 @@ Object* StoreStubCompiler::CompileStoreInterceptor(JSObject* a, String* b) { Object* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, JSGlobalPropertyCell* cell, String* name) { - // TODO(X64): Implement a real stub. - return Failure::InternalError(); + // ----------- S t a t e ------------- + // -- rax : value + // -- rcx : name + // -- rsp[0] : return address + // -- rsp[8] : receiver + // ----------------------------------- + Label miss; + + // Check that the map of the global has not changed. + __ movq(rbx, Operand(rsp, kPointerSize)); + __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset), + Handle(object->map())); + __ j(not_equal, &miss); + + // Store the value in the cell. + __ Move(rcx, Handle(cell)); + __ movq(FieldOperand(rcx, JSGlobalPropertyCell::kValueOffset), rax); + + __ IncrementCounter(&Counters::named_store_global_inline, 1); + // Return the value (register rax). + __ ret(0); + + // Handle store cache miss. + __ bind(&miss); + __ IncrementCounter(&Counters::named_store_global_inline_miss, 1); + Handle ic(Builtins::builtin(Builtins::StoreIC_Miss)); + __ Jump(ic, RelocInfo::CODE_TARGET); + + // Return the generated code. + return GetCode(NORMAL, name); } diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status index d30e78c..6b627e2 100644 --- a/test/mjsunit/mjsunit.status +++ b/test/mjsunit/mjsunit.status @@ -98,7 +98,7 @@ invalid-lhs: PASS || CRASH || FAIL debug-stepin-constructor: CRASH || FAIL debug-stepin-function-call: CRASH || FAIL debug-stepin-accessor: CRASH || FAIL -new: CRASH || FAIL +new: PASS || CRASH || FAIL fuzz-natives: PASS || TIMEOUT greedy: PASS || TIMEOUT debug-handle: CRASH || FAIL -- 2.7.4