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

Side by Side Diff: src/builtins.cc

Issue 1686123002: Revert of Implement symbol @@hasInstance for ES6 instanceof support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/builtins.h ('k') | src/heap-symbols.h » ('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/builtins.h" 5 #include "src/builtins.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 3422 matching lines...) Expand 10 before | Expand all | Expand 10 after
3433 3433
3434 // ES6 section 25.2.1.1 GeneratorFunction (p1, p2, ... , pn, body) 3434 // ES6 section 25.2.1.1 GeneratorFunction (p1, p2, ... , pn, body)
3435 BUILTIN(GeneratorFunctionConstructor) { 3435 BUILTIN(GeneratorFunctionConstructor) {
3436 HandleScope scope(isolate); 3436 HandleScope scope(isolate);
3437 Handle<JSFunction> result; 3437 Handle<JSFunction> result;
3438 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 3438 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
3439 isolate, result, CreateDynamicFunction(isolate, args, "function*")); 3439 isolate, result, CreateDynamicFunction(isolate, args, "function*"));
3440 return *result; 3440 return *result;
3441 } 3441 }
3442 3442
3443 // ES6 section 19.2.3.6 Function.prototype[@@hasInstance](V)
3444 BUILTIN(FunctionHasInstance) {
3445 HandleScope scope(isolate);
3446 Handle<Object> callable = args.receiver();
3447 Handle<Object> object = args.atOrUndefined(isolate, 1);
3448
3449 // {callable} must have a [[Call]] internal method.
3450 if (!callable->IsCallable()) {
3451 return isolate->heap()->false_value();
3452 }
3453 // If {object} is not a receiver, return false.
3454 if (!object->IsJSReceiver()) {
3455 return isolate->heap()->false_value();
3456 }
3457 // Check if {callable} is bound, if so, get [[BoundTargetFunction]] from it
3458 // and use that instead of {callable}.
3459 while (callable->IsJSBoundFunction()) {
3460 callable =
3461 handle(Handle<JSBoundFunction>::cast(callable)->bound_target_function(),
3462 isolate);
3463 }
3464 DCHECK(callable->IsCallable());
3465 // Get the "prototype" of {callable}; raise an error if it's not a receiver.
3466 Handle<Object> prototype;
3467 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
3468 isolate, prototype,
3469 Object::GetProperty(callable, isolate->factory()->prototype_string()));
3470 if (!prototype->IsJSReceiver()) {
3471 THROW_NEW_ERROR_RETURN_FAILURE(
3472 isolate,
3473 NewTypeError(MessageTemplate::kInstanceofNonobjectProto, prototype));
3474 }
3475 // Return whether or not {prototype} is in the prototype chain of {object}.
3476 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object);
3477 Maybe<bool> result =
3478 JSReceiver::HasInPrototypeChain(isolate, receiver, prototype);
3479 MAYBE_RETURN(result, isolate->heap()->exception());
3480 return isolate->heap()->ToBoolean(result.FromJust());
3481 }
3482 3443
3483 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Call]] case. 3444 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Call]] case.
3484 BUILTIN(SymbolConstructor) { 3445 BUILTIN(SymbolConstructor) {
3485 HandleScope scope(isolate); 3446 HandleScope scope(isolate);
3486 Handle<Symbol> result = isolate->factory()->NewSymbol(); 3447 Handle<Symbol> result = isolate->factory()->NewSymbol();
3487 Handle<Object> description = args.atOrUndefined(isolate, 1); 3448 Handle<Object> description = args.atOrUndefined(isolate, 1);
3488 if (!description->IsUndefined()) { 3449 if (!description->IsUndefined()) {
3489 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, description, 3450 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, description,
3490 Object::ToString(isolate, description)); 3451 Object::ToString(isolate, description));
3491 result->set_name(*description); 3452 result->set_name(*description);
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
4270 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 4231 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
4271 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 4232 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
4272 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 4233 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
4273 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 4234 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
4274 #undef DEFINE_BUILTIN_ACCESSOR_C 4235 #undef DEFINE_BUILTIN_ACCESSOR_C
4275 #undef DEFINE_BUILTIN_ACCESSOR_A 4236 #undef DEFINE_BUILTIN_ACCESSOR_A
4276 4237
4277 4238
4278 } // namespace internal 4239 } // namespace internal
4279 } // namespace v8 4240 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/heap-symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698