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

Side by Side Diff: src/bootstrapper.cc

Issue 2026643003: [json] replace remaining json.js code with C++ builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix error message Created 4 years, 6 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 | « BUILD.gn ('k') | src/builtins.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 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/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/extensions/externalize-string-extension.h" 10 #include "src/extensions/externalize-string-extension.h"
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 SimpleInstallFunction(prototype, "getUTCSeconds", 1468 SimpleInstallFunction(prototype, "getUTCSeconds",
1469 Builtins::kDatePrototypeGetUTCSeconds, 0, true); 1469 Builtins::kDatePrototypeGetUTCSeconds, 0, true);
1470 SimpleInstallFunction(prototype, "setUTCSeconds", 1470 SimpleInstallFunction(prototype, "setUTCSeconds",
1471 Builtins::kDatePrototypeSetUTCSeconds, 2, false); 1471 Builtins::kDatePrototypeSetUTCSeconds, 2, false);
1472 SimpleInstallFunction(prototype, "valueOf", Builtins::kDatePrototypeValueOf, 1472 SimpleInstallFunction(prototype, "valueOf", Builtins::kDatePrototypeValueOf,
1473 0, false); 1473 0, false);
1474 SimpleInstallFunction(prototype, "getYear", Builtins::kDatePrototypeGetYear, 1474 SimpleInstallFunction(prototype, "getYear", Builtins::kDatePrototypeGetYear,
1475 0, true); 1475 0, true);
1476 SimpleInstallFunction(prototype, "setYear", Builtins::kDatePrototypeSetYear, 1476 SimpleInstallFunction(prototype, "setYear", Builtins::kDatePrototypeSetYear,
1477 1, false); 1477 1, false);
1478 SimpleInstallFunction(prototype, "toJSON", Builtins::kDatePrototypeToJson,
1479 1, false);
1478 1480
1479 // Install i18n fallback functions. 1481 // Install i18n fallback functions.
1480 SimpleInstallFunction(prototype, "toLocaleString", 1482 SimpleInstallFunction(prototype, "toLocaleString",
1481 Builtins::kDatePrototypeToString, 0, false); 1483 Builtins::kDatePrototypeToString, 0, false);
1482 SimpleInstallFunction(prototype, "toLocaleDateString", 1484 SimpleInstallFunction(prototype, "toLocaleDateString",
1483 Builtins::kDatePrototypeToDateString, 0, false); 1485 Builtins::kDatePrototypeToDateString, 0, false);
1484 SimpleInstallFunction(prototype, "toLocaleTimeString", 1486 SimpleInstallFunction(prototype, "toLocaleTimeString",
1485 Builtins::kDatePrototypeToTimeString, 0, false); 1487 Builtins::kDatePrototypeToTimeString, 0, false);
1486 1488
1487 // Install the @@toPrimitive function. 1489 // Install the @@toPrimitive function.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 if (context_type == THIN_CONTEXT) return; 1596 if (context_type == THIN_CONTEXT) return;
1595 1597
1596 { // -- J S O N 1598 { // -- J S O N
1597 Handle<String> name = factory->InternalizeUtf8String("JSON"); 1599 Handle<String> name = factory->InternalizeUtf8String("JSON");
1598 Handle<JSFunction> cons = factory->NewFunction(name); 1600 Handle<JSFunction> cons = factory->NewFunction(name);
1599 JSFunction::SetInstancePrototype(cons, 1601 JSFunction::SetInstancePrototype(cons,
1600 Handle<Object>(native_context()->initial_object_prototype(), isolate)); 1602 Handle<Object>(native_context()->initial_object_prototype(), isolate));
1601 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); 1603 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED);
1602 DCHECK(json_object->IsJSObject()); 1604 DCHECK(json_object->IsJSObject());
1603 JSObject::AddProperty(global, name, json_object, DONT_ENUM); 1605 JSObject::AddProperty(global, name, json_object, DONT_ENUM);
1606 SimpleInstallFunction(json_object, "parse", Builtins::kJsonParse, 2, true);
1604 SimpleInstallFunction(json_object, "stringify", Builtins::kJsonStringify, 3, 1607 SimpleInstallFunction(json_object, "stringify", Builtins::kJsonStringify, 3,
1605 true); 1608 true);
1609 JSObject::AddProperty(
1610 json_object, factory->to_string_tag_symbol(),
1611 factory->NewStringFromAsciiChecked("JSON"),
1612 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
1606 } 1613 }
1607 1614
1608 { // -- M a t h 1615 { // -- M a t h
1609 Handle<String> name = factory->InternalizeUtf8String("Math"); 1616 Handle<String> name = factory->InternalizeUtf8String("Math");
1610 Handle<JSFunction> cons = factory->NewFunction(name); 1617 Handle<JSFunction> cons = factory->NewFunction(name);
1611 JSFunction::SetInstancePrototype( 1618 JSFunction::SetInstancePrototype(
1612 cons, 1619 cons,
1613 Handle<Object>(native_context()->initial_object_prototype(), isolate)); 1620 Handle<Object>(native_context()->initial_object_prototype(), isolate));
1614 Handle<JSObject> math = factory->NewJSObject(cons, TENURED); 1621 Handle<JSObject> math = factory->NewJSObject(cons, TENURED);
1615 DCHECK(math->IsJSObject()); 1622 DCHECK(math->IsJSObject());
(...skipping 2179 matching lines...) Expand 10 before | Expand all | Expand 10 after
3795 } 3802 }
3796 3803
3797 3804
3798 // Called when the top-level V8 mutex is destroyed. 3805 // Called when the top-level V8 mutex is destroyed.
3799 void Bootstrapper::FreeThreadResources() { 3806 void Bootstrapper::FreeThreadResources() {
3800 DCHECK(!IsActive()); 3807 DCHECK(!IsActive());
3801 } 3808 }
3802 3809
3803 } // namespace internal 3810 } // namespace internal
3804 } // namespace v8 3811 } // namespace v8
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698