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

Side by Side Diff: src/bootstrapper.cc

Issue 2117273002: Revert of [intrinsic] Drop the %_ValueOf intrinsic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | 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/base/ieee754.h" 9 #include "src/base/ieee754.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 { // --- N u m b e r --- 1304 { // --- N u m b e r ---
1305 Handle<JSFunction> number_fun = InstallFunction( 1305 Handle<JSFunction> number_fun = InstallFunction(
1306 global, "Number", JS_VALUE_TYPE, JSValue::kSize, 1306 global, "Number", JS_VALUE_TYPE, JSValue::kSize,
1307 isolate->initial_object_prototype(), Builtins::kNumberConstructor); 1307 isolate->initial_object_prototype(), Builtins::kNumberConstructor);
1308 number_fun->shared()->DontAdaptArguments(); 1308 number_fun->shared()->DontAdaptArguments();
1309 number_fun->shared()->set_construct_stub( 1309 number_fun->shared()->set_construct_stub(
1310 *isolate->builtins()->NumberConstructor_ConstructStub()); 1310 *isolate->builtins()->NumberConstructor_ConstructStub());
1311 number_fun->shared()->set_length(1); 1311 number_fun->shared()->set_length(1);
1312 InstallWithIntrinsicDefaultProto(isolate, number_fun, 1312 InstallWithIntrinsicDefaultProto(isolate, number_fun,
1313 Context::NUMBER_FUNCTION_INDEX); 1313 Context::NUMBER_FUNCTION_INDEX);
1314
1315 // Create the %NumberPrototype%
1316 Handle<JSValue> prototype =
1317 Handle<JSValue>::cast(factory->NewJSObject(number_fun, TENURED));
1318 prototype->set_value(Smi::FromInt(0));
1319 Accessors::FunctionSetPrototype(number_fun, prototype).Assert();
1320
1321 // Install the "constructor" property on the {prototype}.
1322 JSObject::AddProperty(prototype, factory->constructor_string(), number_fun,
1323 DONT_ENUM);
1324
1325 // Install the Number.prototype methods.
1326 SimpleInstallFunction(prototype, "toExponential",
1327 Builtins::kNumberPrototypeToExponential, 1, false);
1328 SimpleInstallFunction(prototype, "toFixed",
1329 Builtins::kNumberPrototypeToFixed, 1, false);
1330 SimpleInstallFunction(prototype, "toPrecision",
1331 Builtins::kNumberPrototypeToPrecision, 1, false);
1332 SimpleInstallFunction(prototype, "toString",
1333 Builtins::kNumberPrototypeToString, 1, false);
1334 SimpleInstallFunction(prototype, "valueOf",
1335 Builtins::kNumberPrototypeValueOf, 0, true);
1336
1337 // Install i18n fallback functions.
1338 SimpleInstallFunction(prototype, "toLocaleString",
1339 Builtins::kNumberPrototypeToString, 1, true);
1340 } 1314 }
1341 1315
1342 { // --- B o o l e a n --- 1316 { // --- B o o l e a n ---
1343 Handle<JSFunction> boolean_fun = 1317 Handle<JSFunction> boolean_fun =
1344 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, 1318 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize,
1345 isolate->initial_object_prototype(), 1319 isolate->initial_object_prototype(),
1346 Builtins::kBooleanConstructor); 1320 Builtins::kBooleanConstructor);
1347 boolean_fun->shared()->DontAdaptArguments(); 1321 boolean_fun->shared()->DontAdaptArguments();
1348 boolean_fun->shared()->set_construct_stub( 1322 boolean_fun->shared()->set_construct_stub(
1349 *isolate->builtins()->BooleanConstructor_ConstructStub()); 1323 *isolate->builtins()->BooleanConstructor_ConstructStub());
1350 boolean_fun->shared()->set_length(1); 1324 boolean_fun->shared()->set_length(1);
1351 InstallWithIntrinsicDefaultProto(isolate, boolean_fun, 1325 InstallWithIntrinsicDefaultProto(isolate, boolean_fun,
1352 Context::BOOLEAN_FUNCTION_INDEX); 1326 Context::BOOLEAN_FUNCTION_INDEX);
1353 1327
1354 // Create the %BooleanPrototype% 1328 // Create the %BooleanPrototype%
1355 Handle<JSValue> prototype = 1329 Handle<JSValue> prototype =
1356 Handle<JSValue>::cast(factory->NewJSObject(boolean_fun, TENURED)); 1330 Handle<JSValue>::cast(factory->NewJSObject(boolean_fun, TENURED));
1357 prototype->set_value(isolate->heap()->false_value()); 1331 prototype->set_value(isolate->heap()->false_value());
1358 Accessors::FunctionSetPrototype(boolean_fun, prototype).Assert(); 1332 Accessors::FunctionSetPrototype(boolean_fun, prototype).Assert();
1359 1333
1360 // Install the "constructor" property on the {prototype}. 1334 // Install the "constructor" property on the {prototype}.
1361 JSObject::AddProperty(prototype, factory->constructor_string(), boolean_fun, 1335 JSObject::AddProperty(prototype, factory->constructor_string(), boolean_fun,
1362 DONT_ENUM); 1336 DONT_ENUM);
1363 1337
1364 // Install the Boolean.prototype methods. 1338 // Install the Boolean.prototype methods.
1365 SimpleInstallFunction(prototype, "toString", 1339 SimpleInstallFunction(prototype, "toString",
1366 Builtins::kBooleanPrototypeToString, 0, true); 1340 Builtins::kBooleanPrototypeToString, 0, false);
1367 SimpleInstallFunction(prototype, "valueOf", 1341 SimpleInstallFunction(prototype, "valueOf",
1368 Builtins::kBooleanPrototypeValueOf, 0, true); 1342 Builtins::kBooleanPrototypeValueOf, 0, false);
1369 } 1343 }
1370 1344
1371 { // --- S t r i n g --- 1345 { // --- S t r i n g ---
1372 Handle<JSFunction> string_fun = InstallFunction( 1346 Handle<JSFunction> string_fun = InstallFunction(
1373 global, "String", JS_VALUE_TYPE, JSValue::kSize, 1347 global, "String", JS_VALUE_TYPE, JSValue::kSize,
1374 isolate->initial_object_prototype(), Builtins::kStringConstructor); 1348 isolate->initial_object_prototype(), Builtins::kStringConstructor);
1375 string_fun->shared()->set_construct_stub( 1349 string_fun->shared()->set_construct_stub(
1376 *isolate->builtins()->StringConstructor_ConstructStub()); 1350 *isolate->builtins()->StringConstructor_ConstructStub());
1377 string_fun->shared()->DontAdaptArguments(); 1351 string_fun->shared()->DontAdaptArguments();
1378 string_fun->shared()->set_length(1); 1352 string_fun->shared()->set_length(1);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 1385
1412 // Install the "constructor" property on the {prototype}. 1386 // Install the "constructor" property on the {prototype}.
1413 JSObject::AddProperty(prototype, factory->constructor_string(), string_fun, 1387 JSObject::AddProperty(prototype, factory->constructor_string(), string_fun,
1414 DONT_ENUM); 1388 DONT_ENUM);
1415 1389
1416 // Install the String.prototype methods. 1390 // Install the String.prototype methods.
1417 SimpleInstallFunction(prototype, "charAt", Builtins::kStringPrototypeCharAt, 1391 SimpleInstallFunction(prototype, "charAt", Builtins::kStringPrototypeCharAt,
1418 1, true); 1392 1, true);
1419 SimpleInstallFunction(prototype, "charCodeAt", 1393 SimpleInstallFunction(prototype, "charCodeAt",
1420 Builtins::kStringPrototypeCharCodeAt, 1, true); 1394 Builtins::kStringPrototypeCharCodeAt, 1, true);
1421 SimpleInstallFunction(prototype, "toString",
1422 Builtins::kStringPrototypeToString, 0, true);
1423 SimpleInstallFunction(prototype, "trim", Builtins::kStringPrototypeTrim, 0, 1395 SimpleInstallFunction(prototype, "trim", Builtins::kStringPrototypeTrim, 0,
1424 false); 1396 false);
1425 SimpleInstallFunction(prototype, "trimLeft", 1397 SimpleInstallFunction(prototype, "trimLeft",
1426 Builtins::kStringPrototypeTrimLeft, 0, false); 1398 Builtins::kStringPrototypeTrimLeft, 0, false);
1427 SimpleInstallFunction(prototype, "trimRight", 1399 SimpleInstallFunction(prototype, "trimRight",
1428 Builtins::kStringPrototypeTrimRight, 0, false); 1400 Builtins::kStringPrototypeTrimRight, 0, false);
1429 SimpleInstallFunction(prototype, "valueOf",
1430 Builtins::kStringPrototypeValueOf, 0, true);
1431 } 1401 }
1432 1402
1433 { 1403 {
1434 // --- S y m b o l --- 1404 // --- S y m b o l ---
1435 Handle<JSObject> prototype = 1405 Handle<JSObject> prototype =
1436 factory->NewJSObject(isolate->object_function(), TENURED); 1406 factory->NewJSObject(isolate->object_function(), TENURED);
1437 Handle<JSFunction> symbol_fun = 1407 Handle<JSFunction> symbol_fun =
1438 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, 1408 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize,
1439 prototype, Builtins::kSymbolConstructor); 1409 prototype, Builtins::kSymbolConstructor);
1440 symbol_fun->shared()->set_construct_stub( 1410 symbol_fun->shared()->set_construct_stub(
1441 *isolate->builtins()->SymbolConstructor_ConstructStub()); 1411 *isolate->builtins()->SymbolConstructor_ConstructStub());
1442 symbol_fun->shared()->set_length(0); 1412 symbol_fun->shared()->set_length(0);
1443 symbol_fun->shared()->DontAdaptArguments(); 1413 symbol_fun->shared()->DontAdaptArguments();
1444 native_context()->set_symbol_function(*symbol_fun); 1414 native_context()->set_symbol_function(*symbol_fun);
1445 1415
1446 // Install the @@toStringTag property on the {prototype}.
1447 JSObject::AddProperty(
1448 prototype, factory->to_string_tag_symbol(),
1449 factory->NewStringFromAsciiChecked("Symbol"),
1450 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
1451
1452 // Install the "constructor" property on the {prototype}. 1416 // Install the "constructor" property on the {prototype}.
1453 JSObject::AddProperty(prototype, factory->constructor_string(), symbol_fun, 1417 JSObject::AddProperty(prototype, factory->constructor_string(), symbol_fun,
1454 DONT_ENUM); 1418 DONT_ENUM);
1455
1456 // Install the Symbol.prototype methods.
1457 SimpleInstallFunction(prototype, "toString",
1458 Builtins::kSymbolPrototypeToString, 0, true);
1459 SimpleInstallFunction(prototype, "valueOf",
1460 Builtins::kSymbolPrototypeValueOf, 0, true);
1461
1462 // Install the @@toPrimitive function.
1463 Handle<JSFunction> to_primitive = InstallFunction(
1464 prototype, factory->to_primitive_symbol(), JS_OBJECT_TYPE,
1465 JSObject::kHeaderSize, MaybeHandle<JSObject>(),
1466 Builtins::kSymbolPrototypeToPrimitive,
1467 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
1468
1469 // Set the expected parameters for @@toPrimitive to 1; required by builtin.
1470 to_primitive->shared()->set_internal_formal_parameter_count(1);
1471
1472 // Set the length for the function to satisfy ECMA-262.
1473 to_primitive->shared()->set_length(1);
1474 } 1419 }
1475 1420
1476 { // --- D a t e --- 1421 { // --- D a t e ---
1477 // Builtin functions for Date.prototype. 1422 // Builtin functions for Date.prototype.
1478 Handle<JSObject> prototype = 1423 Handle<JSObject> prototype =
1479 factory->NewJSObject(isolate->object_function(), TENURED); 1424 factory->NewJSObject(isolate->object_function(), TENURED);
1480 Handle<JSFunction> date_fun = 1425 Handle<JSFunction> date_fun =
1481 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, prototype, 1426 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, prototype,
1482 Builtins::kDateConstructor); 1427 Builtins::kDateConstructor);
1483 InstallWithIntrinsicDefaultProto(isolate, date_fun, 1428 InstallWithIntrinsicDefaultProto(isolate, date_fun,
(...skipping 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after
4010 } 3955 }
4011 3956
4012 3957
4013 // Called when the top-level V8 mutex is destroyed. 3958 // Called when the top-level V8 mutex is destroyed.
4014 void Bootstrapper::FreeThreadResources() { 3959 void Bootstrapper::FreeThreadResources() {
4015 DCHECK(!IsActive()); 3960 DCHECK(!IsActive());
4016 } 3961 }
4017 3962
4018 } // namespace internal 3963 } // namespace internal
4019 } // namespace v8 3964 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698