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

Side by Side Diff: src/bootstrapper.cc

Issue 2848313004: Mark Number and String as strict functions (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | test/mjsunit/mjsunit.status » ('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/base/ieee754.h" 9 #include "src/base/ieee754.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 } 1587 }
1588 1588
1589 { // --- N u m b e r --- 1589 { // --- N u m b e r ---
1590 Handle<JSFunction> number_fun = InstallFunction( 1590 Handle<JSFunction> number_fun = InstallFunction(
1591 global, "Number", JS_VALUE_TYPE, JSValue::kSize, 1591 global, "Number", JS_VALUE_TYPE, JSValue::kSize,
1592 isolate->initial_object_prototype(), Builtins::kNumberConstructor); 1592 isolate->initial_object_prototype(), Builtins::kNumberConstructor);
1593 number_fun->shared()->DontAdaptArguments(); 1593 number_fun->shared()->DontAdaptArguments();
1594 number_fun->shared()->SetConstructStub( 1594 number_fun->shared()->SetConstructStub(
1595 *isolate->builtins()->NumberConstructor_ConstructStub()); 1595 *isolate->builtins()->NumberConstructor_ConstructStub());
1596 number_fun->shared()->set_length(1); 1596 number_fun->shared()->set_length(1);
1597 // https://tc39.github.io/ecma262/#sec-built-in-function-objects says
1598 // that "Built-in functions that are ECMAScript function objects must
1599 // be strict functions".
1600 number_fun->shared()->set_language_mode(STRICT);
1597 InstallWithIntrinsicDefaultProto(isolate, number_fun, 1601 InstallWithIntrinsicDefaultProto(isolate, number_fun,
1598 Context::NUMBER_FUNCTION_INDEX); 1602 Context::NUMBER_FUNCTION_INDEX);
1599 1603
1600 // Create the %NumberPrototype% 1604 // Create the %NumberPrototype%
1601 Handle<JSValue> prototype = 1605 Handle<JSValue> prototype =
1602 Handle<JSValue>::cast(factory->NewJSObject(number_fun, TENURED)); 1606 Handle<JSValue>::cast(factory->NewJSObject(number_fun, TENURED));
1603 prototype->set_value(Smi::kZero); 1607 prototype->set_value(Smi::kZero);
1604 JSFunction::SetPrototype(number_fun, prototype); 1608 JSFunction::SetPrototype(number_fun, prototype);
1605 1609
1606 // Install the "constructor" property on the {prototype}. 1610 // Install the "constructor" property on the {prototype}.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 } 1736 }
1733 1737
1734 { // --- S t r i n g --- 1738 { // --- S t r i n g ---
1735 Handle<JSFunction> string_fun = InstallFunction( 1739 Handle<JSFunction> string_fun = InstallFunction(
1736 global, "String", JS_VALUE_TYPE, JSValue::kSize, 1740 global, "String", JS_VALUE_TYPE, JSValue::kSize,
1737 isolate->initial_object_prototype(), Builtins::kStringConstructor); 1741 isolate->initial_object_prototype(), Builtins::kStringConstructor);
1738 string_fun->shared()->SetConstructStub( 1742 string_fun->shared()->SetConstructStub(
1739 *isolate->builtins()->StringConstructor_ConstructStub()); 1743 *isolate->builtins()->StringConstructor_ConstructStub());
1740 string_fun->shared()->DontAdaptArguments(); 1744 string_fun->shared()->DontAdaptArguments();
1741 string_fun->shared()->set_length(1); 1745 string_fun->shared()->set_length(1);
1746 // https://tc39.github.io/ecma262/#sec-built-in-function-objects says
1747 // that "Built-in functions that are ECMAScript function objects must
1748 // be strict functions".
1749 string_fun->shared()->set_language_mode(STRICT);
1742 InstallWithIntrinsicDefaultProto(isolate, string_fun, 1750 InstallWithIntrinsicDefaultProto(isolate, string_fun,
1743 Context::STRING_FUNCTION_INDEX); 1751 Context::STRING_FUNCTION_INDEX);
1744 1752
1745 Handle<Map> string_map = 1753 Handle<Map> string_map =
1746 Handle<Map>(native_context()->string_function()->initial_map()); 1754 Handle<Map>(native_context()->string_function()->initial_map());
1747 string_map->set_elements_kind(FAST_STRING_WRAPPER_ELEMENTS); 1755 string_map->set_elements_kind(FAST_STRING_WRAPPER_ELEMENTS);
1748 Map::EnsureDescriptorSlack(string_map, 1); 1756 Map::EnsureDescriptorSlack(string_map, 1);
1749 1757
1750 PropertyAttributes attribs = static_cast<PropertyAttributes>( 1758 PropertyAttributes attribs = static_cast<PropertyAttributes>(
1751 DONT_ENUM | DONT_DELETE | READ_ONLY); 1759 DONT_ENUM | DONT_DELETE | READ_ONLY);
(...skipping 3519 matching lines...) Expand 10 before | Expand all | Expand 10 after
5271 } 5279 }
5272 5280
5273 5281
5274 // Called when the top-level V8 mutex is destroyed. 5282 // Called when the top-level V8 mutex is destroyed.
5275 void Bootstrapper::FreeThreadResources() { 5283 void Bootstrapper::FreeThreadResources() {
5276 DCHECK(!IsActive()); 5284 DCHECK(!IsActive());
5277 } 5285 }
5278 5286
5279 } // namespace internal 5287 } // namespace internal
5280 } // namespace v8 5288 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698