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

Side by Side Diff: src/runtime/runtime-object.cc

Issue 1542963002: [runtime] Introduce dedicated JSBoundFunction to represent bound functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@FunctionConstructor
Patch Set: [arm64] Poke does not preserve flags with --debug-code. Created 4 years, 12 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/runtime/runtime-function.cc ('k') | src/runtime/runtime-observe.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 // {callable} must have a [[Call]] internal method. 1339 // {callable} must have a [[Call]] internal method.
1340 if (!callable->IsCallable()) { 1340 if (!callable->IsCallable()) {
1341 THROW_NEW_ERROR_RETURN_FAILURE( 1341 THROW_NEW_ERROR_RETURN_FAILURE(
1342 isolate, 1342 isolate,
1343 NewTypeError(MessageTemplate::kInstanceofFunctionExpected, callable)); 1343 NewTypeError(MessageTemplate::kInstanceofFunctionExpected, callable));
1344 } 1344 }
1345 // If {object} is not a receiver, return false. 1345 // If {object} is not a receiver, return false.
1346 if (!object->IsJSReceiver()) { 1346 if (!object->IsJSReceiver()) {
1347 return isolate->heap()->false_value(); 1347 return isolate->heap()->false_value();
1348 } 1348 }
1349 // Check if {callable} is bound, if so, get [[BoundFunction]] from it and use 1349 // Check if {callable} is bound, if so, get [[BoundTargetFunction]] from it
1350 // that instead of {callable}. 1350 // and use that instead of {callable}.
1351 if (callable->IsJSFunction()) { 1351 while (callable->IsJSBoundFunction()) {
1352 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); 1352 callable =
1353 if (function->shared()->bound()) { 1353 handle(Handle<JSBoundFunction>::cast(callable)->bound_target_function(),
1354 Handle<BindingsArray> bindings(function->function_bindings(), isolate); 1354 isolate);
1355 callable = handle(bindings->bound_function(), isolate);
1356 }
1357 } 1355 }
1358 DCHECK(callable->IsCallable()); 1356 DCHECK(callable->IsCallable());
1359 // Get the "prototype" of {callable}; raise an error if it's not a receiver. 1357 // Get the "prototype" of {callable}; raise an error if it's not a receiver.
1360 Handle<Object> prototype; 1358 Handle<Object> prototype;
1361 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1359 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1362 isolate, prototype, 1360 isolate, prototype,
1363 Object::GetProperty(callable, isolate->factory()->prototype_string())); 1361 Object::GetProperty(callable, isolate->factory()->prototype_string()));
1364 if (!prototype->IsJSReceiver()) { 1362 if (!prototype->IsJSReceiver()) {
1365 THROW_NEW_ERROR_RETURN_FAILURE( 1363 THROW_NEW_ERROR_RETURN_FAILURE(
1366 isolate, 1364 isolate,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 1412
1415 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { 1413 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) {
1416 HandleScope scope(isolate); 1414 HandleScope scope(isolate);
1417 DCHECK(args.length() == 2); 1415 DCHECK(args.length() == 2);
1418 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); 1416 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0);
1419 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); 1417 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1);
1420 return JSReceiver::DefineProperties(isolate, o, properties); 1418 return JSReceiver::DefineProperties(isolate, o, properties);
1421 } 1419 }
1422 } // namespace internal 1420 } // namespace internal
1423 } // namespace v8 1421 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | src/runtime/runtime-observe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698