Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: src/accessors.cc

Issue 1678953004: [builtins] Remove bunch of uses of %_Arguments and %_ArgumentsLength. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Fix deoptimizer adapted arguments materialization for builtins. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/accessors.h ('k') | src/debug/debug-evaluate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/accessors.h" 5 #include "src/accessors.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/contexts.h" 8 #include "src/contexts.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 DisallowHeapAllocation no_allocation; 937 DisallowHeapAllocation no_allocation;
938 List<JSFunction*> functions(2); 938 List<JSFunction*> functions(2);
939 frame->GetFunctions(&functions); 939 frame->GetFunctions(&functions);
940 for (int i = functions.length() - 1; i >= 0; i--) { 940 for (int i = functions.length() - 1; i >= 0; i--) {
941 if (functions[i] == *function) return i; 941 if (functions[i] == *function) return i;
942 } 942 }
943 return -1; 943 return -1;
944 } 944 }
945 945
946 946
947 namespace {
948
947 Handle<Object> GetFunctionArguments(Isolate* isolate, 949 Handle<Object> GetFunctionArguments(Isolate* isolate,
948 Handle<JSFunction> function) { 950 Handle<JSFunction> function) {
949 if (function->shared()->native()) return isolate->factory()->null_value();
950
951 // Find the top invocation of the function by traversing frames. 951 // Find the top invocation of the function by traversing frames.
952 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { 952 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
953 JavaScriptFrame* frame = it.frame(); 953 JavaScriptFrame* frame = it.frame();
954 int function_index = FindFunctionInFrame(frame, function); 954 int function_index = FindFunctionInFrame(frame, function);
955 if (function_index < 0) continue; 955 if (function_index < 0) continue;
956 956
957 if (function_index > 0) { 957 if (function_index > 0) {
958 // The function in question was inlined. Inlined functions have the 958 // The function in question was inlined. Inlined functions have the
959 // correct number of arguments and no allocated arguments object, so 959 // correct number of arguments and no allocated arguments object, so
960 // we can construct a fresh one by interpreting the function's 960 // we can construct a fresh one by interpreting the function's
(...skipping 18 matching lines...) Expand all
979 arguments->set_elements(*array); 979 arguments->set_elements(*array);
980 980
981 // Return the freshly allocated arguments object. 981 // Return the freshly allocated arguments object.
982 return arguments; 982 return arguments;
983 } 983 }
984 984
985 // No frame corresponding to the given function found. Return null. 985 // No frame corresponding to the given function found. Return null.
986 return isolate->factory()->null_value(); 986 return isolate->factory()->null_value();
987 } 987 }
988 988
989 } // namespace
989 990
990 Handle<Object> Accessors::FunctionGetArguments(Handle<JSFunction> function) { 991
991 return GetFunctionArguments(function->GetIsolate(), function); 992 Handle<JSObject> Accessors::FunctionGetArguments(Handle<JSFunction> function) {
993 Handle<Object> arguments =
994 GetFunctionArguments(function->GetIsolate(), function);
995 CHECK(arguments->IsJSObject());
996 return Handle<JSObject>::cast(arguments);
992 } 997 }
993 998
994 999
995 void Accessors::FunctionArgumentsGetter( 1000 void Accessors::FunctionArgumentsGetter(
996 v8::Local<v8::Name> name, 1001 v8::Local<v8::Name> name,
997 const v8::PropertyCallbackInfo<v8::Value>& info) { 1002 const v8::PropertyCallbackInfo<v8::Value>& info) {
998 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 1003 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
999 HandleScope scope(isolate); 1004 HandleScope scope(isolate);
1000 Handle<JSFunction> function = 1005 Handle<JSFunction> function =
1001 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); 1006 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder()));
1002 Handle<Object> result = GetFunctionArguments(isolate, function); 1007 Handle<Object> result =
1008 function->shared()->native()
1009 ? Handle<Object>::cast(isolate->factory()->null_value())
1010 : GetFunctionArguments(isolate, function);
1003 info.GetReturnValue().Set(Utils::ToLocal(result)); 1011 info.GetReturnValue().Set(Utils::ToLocal(result));
1004 } 1012 }
1005 1013
1006 1014
1007 Handle<AccessorInfo> Accessors::FunctionArgumentsInfo( 1015 Handle<AccessorInfo> Accessors::FunctionArgumentsInfo(
1008 Isolate* isolate, PropertyAttributes attributes) { 1016 Isolate* isolate, PropertyAttributes attributes) {
1009 return MakeAccessor(isolate, isolate->factory()->arguments_string(), 1017 return MakeAccessor(isolate, isolate->factory()->arguments_string(),
1010 &FunctionArgumentsGetter, nullptr, attributes); 1018 &FunctionArgumentsGetter, nullptr, attributes);
1011 } 1019 }
1012 1020
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 Isolate* isolate = name->GetIsolate(); 1205 Isolate* isolate = name->GetIsolate();
1198 Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport, 1206 Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport,
1199 &ModuleSetExport, attributes); 1207 &ModuleSetExport, attributes);
1200 info->set_data(Smi::FromInt(index)); 1208 info->set_data(Smi::FromInt(index));
1201 return info; 1209 return info;
1202 } 1210 }
1203 1211
1204 1212
1205 } // namespace internal 1213 } // namespace internal
1206 } // namespace v8 1214 } // namespace v8
OLDNEW
« no previous file with comments | « src/accessors.h ('k') | src/debug/debug-evaluate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698