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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/builtins.h ('k') | src/symbol.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index ac6c9fa93a5d4d5fcba83fbd3e0e56a8276b813c..87f1037ceae6e5f5dd8569932bf94f71b1bcfef9 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -1445,11 +1445,7 @@ BUILTIN(ArrayConcat) {
}
-// -----------------------------------------------------------------------------
-//
-
-
-// 20.3.4.45 Date.prototype [ @@toPrimitive ] ( hint )
+// ES6 section 20.3.4.45 Date.prototype [ @@toPrimitive ] ( hint )
BUILTIN(DateToPrimitive) {
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
@@ -1469,6 +1465,30 @@ BUILTIN(DateToPrimitive) {
}
+// ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Call]] case.
+BUILTIN(SymbolConstructor) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ Handle<Symbol> result = isolate->factory()->NewSymbol();
+ Handle<Object> description = args.at<Object>(1);
+ if (!description->IsUndefined()) {
+ 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
+ Object::ToString(isolate, description));
+ result->set_name(*description);
+ }
+ return *result;
+}
+
+
+// ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Construct]] case.
+BUILTIN(SymbolConstructor_ConstructStub) {
+ HandleScope scope(isolate);
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewTypeError(MessageTemplate::kNotConstructor,
+ isolate->factory()->Symbol_string()));
+}
+
+
// -----------------------------------------------------------------------------
// Throwers for restricted function properties and strict arguments object
// properties
« 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