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

Side by Side Diff: src/builtins.cc

Issue 1349643002: [builtins] Also simplify the Symbol constructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@StringConstructor
Patch Set: Fix off-by-1 in DCHECK. Created 5 years, 3 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/symbol.js » ('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 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 1438
1439 Handle<JSArray> result_array; 1439 Handle<JSArray> result_array;
1440 if (Fast_ArrayConcat(isolate, &args).ToHandle(&result_array)) { 1440 if (Fast_ArrayConcat(isolate, &args).ToHandle(&result_array)) {
1441 return *result_array; 1441 return *result_array;
1442 } 1442 }
1443 if (isolate->has_pending_exception()) return isolate->heap()->exception(); 1443 if (isolate->has_pending_exception()) return isolate->heap()->exception();
1444 return Slow_ArrayConcat(&args, isolate); 1444 return Slow_ArrayConcat(&args, isolate);
1445 } 1445 }
1446 1446
1447 1447
1448 // ----------------------------------------------------------------------------- 1448 // ES6 section 20.3.4.45 Date.prototype [ @@toPrimitive ] ( hint )
1449 //
1450
1451
1452 // 20.3.4.45 Date.prototype [ @@toPrimitive ] ( hint )
1453 BUILTIN(DateToPrimitive) { 1449 BUILTIN(DateToPrimitive) {
1454 HandleScope scope(isolate); 1450 HandleScope scope(isolate);
1455 DCHECK_EQ(2, args.length()); 1451 DCHECK_EQ(2, args.length());
1456 if (!args.receiver()->IsJSReceiver()) { 1452 if (!args.receiver()->IsJSReceiver()) {
1457 THROW_NEW_ERROR_RETURN_FAILURE( 1453 THROW_NEW_ERROR_RETURN_FAILURE(
1458 isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, 1454 isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
1459 isolate->factory()->NewStringFromAsciiChecked( 1455 isolate->factory()->NewStringFromAsciiChecked(
1460 "Date.prototype [ @@toPrimitive ]"), 1456 "Date.prototype [ @@toPrimitive ]"),
1461 args.receiver())); 1457 args.receiver()));
1462 } 1458 }
1463 Handle<JSReceiver> receiver = args.at<JSReceiver>(0); 1459 Handle<JSReceiver> receiver = args.at<JSReceiver>(0);
1464 Handle<Object> hint = args.at<Object>(1); 1460 Handle<Object> hint = args.at<Object>(1);
1465 Handle<Object> result; 1461 Handle<Object> result;
1466 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, 1462 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
1467 JSDate::ToPrimitive(receiver, hint)); 1463 JSDate::ToPrimitive(receiver, hint));
1468 return *result; 1464 return *result;
1469 } 1465 }
1470 1466
1471 1467
1468 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Call]] case.
1469 BUILTIN(SymbolConstructor) {
1470 HandleScope scope(isolate);
1471 DCHECK_EQ(2, args.length());
1472 Handle<Symbol> result = isolate->factory()->NewSymbol();
1473 Handle<Object> description = args.at<Object>(1);
1474 if (!description->IsUndefined()) {
1475 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, description,
adamk 2015/09/16 19:33:31 I'd like to understand why this approach is better
Benedikt Meurer 2015/09/17 02:58:10 The main point of these cleanups is to make it cor
1476 Object::ToString(isolate, description));
1477 result->set_name(*description);
1478 }
1479 return *result;
1480 }
1481
1482
1483 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Construct]] case.
1484 BUILTIN(SymbolConstructor_ConstructStub) {
1485 HandleScope scope(isolate);
1486 THROW_NEW_ERROR_RETURN_FAILURE(
1487 isolate, NewTypeError(MessageTemplate::kNotConstructor,
1488 isolate->factory()->Symbol_string()));
1489 }
1490
1491
1472 // ----------------------------------------------------------------------------- 1492 // -----------------------------------------------------------------------------
1473 // Throwers for restricted function properties and strict arguments object 1493 // Throwers for restricted function properties and strict arguments object
1474 // properties 1494 // properties
1475 1495
1476 1496
1477 BUILTIN(RestrictedFunctionPropertiesThrower) { 1497 BUILTIN(RestrictedFunctionPropertiesThrower) {
1478 HandleScope scope(isolate); 1498 HandleScope scope(isolate);
1479 THROW_NEW_ERROR_RETURN_FAILURE( 1499 THROW_NEW_ERROR_RETURN_FAILURE(
1480 isolate, NewTypeError(MessageTemplate::kRestrictedFunctionProperties)); 1500 isolate, NewTypeError(MessageTemplate::kRestrictedFunctionProperties));
1481 } 1501 }
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 2090 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
2071 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 2091 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
2072 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 2092 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
2073 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 2093 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
2074 #undef DEFINE_BUILTIN_ACCESSOR_C 2094 #undef DEFINE_BUILTIN_ACCESSOR_C
2075 #undef DEFINE_BUILTIN_ACCESSOR_A 2095 #undef DEFINE_BUILTIN_ACCESSOR_A
2076 2096
2077 2097
2078 } // namespace internal 2098 } // namespace internal
2079 } // namespace v8 2099 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/symbol.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698