From 4491e0e12ec2894b9eca4db29d47136dd84d049b Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Fri, 1 Aug 2014 09:23:07 +0000 Subject: [PATCH] Implement lowering of JSStoreContext to machine operators. R=titzer@chromium.org Review URL: https://codereview.chromium.org/420073004 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22783 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/compiler/js-generic-lowering.cc | 16 +++++++++++++--- src/runtime.cc | 16 ---------------- src/runtime.h | 1 - tools/generate-runtime-tests.py | 4 ++-- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/compiler/js-generic-lowering.cc b/src/compiler/js-generic-lowering.cc index 3526715..f87006f 100644 --- a/src/compiler/js-generic-lowering.cc +++ b/src/compiler/js-generic-lowering.cc @@ -388,9 +388,19 @@ Node* JSGenericLowering::LowerJSLoadContext(Node* node) { Node* JSGenericLowering::LowerJSStoreContext(Node* node) { ContextAccess access = OpParameter(node); - PatchInsertInput(node, 1, SmiConstant(access.depth())); - PatchInsertInput(node, 2, SmiConstant(access.index())); - ReplaceWithRuntimeCall(node, Runtime::kStoreContextRelative, 4); + // TODO(mstarzinger): Use simplified operators instead of machine operators + // here so that load/store optimization can be applied afterwards. + for (int i = 0; i < access.depth(); ++i) { + node->ReplaceInput( + 0, graph()->NewNode( + machine()->Load(kMachineTagged), + NodeProperties::GetValueInput(node, 0), + Int32Constant(Context::SlotOffset(Context::PREVIOUS_INDEX)), + NodeProperties::GetEffectInput(node))); + } + node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1)); + node->ReplaceInput(1, Int32Constant(Context::SlotOffset(access.index()))); + PatchOperator(node, machine()->Store(kMachineTagged, kFullWriteBarrier)); return node; } diff --git a/src/runtime.cc b/src/runtime.cc index 63d6ea2..18ac790 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -9408,22 +9408,6 @@ RUNTIME_FUNCTION(Runtime_StoreLookupSlot) { } -RUNTIME_FUNCTION(Runtime_StoreContextRelative) { - SealHandleScope shs(isolate); - ASSERT(args.length() == 4); - CONVERT_ARG_CHECKED(Context, context, 0); - CONVERT_SMI_ARG_CHECKED(depth, 1); - CONVERT_SMI_ARG_CHECKED(index, 2); - CONVERT_ARG_CHECKED(Object, value, 3); - while (depth-- > 0) { - context = context->previous(); - ASSERT(context->IsContext()); - } - context->set(index, value); - return isolate->heap()->undefined_value(); -} - - RUNTIME_FUNCTION(Runtime_Throw) { HandleScope scope(isolate); ASSERT(args.length() == 1); diff --git a/src/runtime.h b/src/runtime.h index 67e6148..381d4d5 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -481,7 +481,6 @@ namespace internal { F(LoadLookupSlot, 2, 2) \ F(LoadLookupSlotNoReferenceError, 2, 2) \ F(StoreLookupSlot, 4, 1) \ - F(StoreContextRelative, 4, 1) /* TODO(turbofan): Only temporary */ \ \ /* Declarations and initialization */ \ F(DeclareGlobals, 3, 1) \ diff --git a/tools/generate-runtime-tests.py b/tools/generate-runtime-tests.py index d766409..5817539 100755 --- a/tools/generate-runtime-tests.py +++ b/tools/generate-runtime-tests.py @@ -47,9 +47,9 @@ EXPAND_MACROS = [ # that the parser doesn't bit-rot. Change the values as needed when you add, # remove or change runtime functions, but make sure we don't lose our ability # to parse them! -EXPECTED_FUNCTION_COUNT = 426 +EXPECTED_FUNCTION_COUNT = 425 EXPECTED_FUZZABLE_COUNT = 338 -EXPECTED_CCTEST_COUNT = 10 +EXPECTED_CCTEST_COUNT = 9 EXPECTED_UNKNOWN_COUNT = 4 EXPECTED_BUILTINS_COUNT = 816 -- 2.7.4