Commit 024c4ff0 authored by loorongjie's avatar loorongjie Committed by Commit bot

Migrate Number constants and undefined to C++

BUG=v8:6005
R=bmeurer@chromium.org

Review-Url: https://codereview.chromium.org/2715793004
Cr-Commit-Position: refs/heads/master@{#43438}
parent 9da6ab2a
# Below is a list of people and organizations that have contributed
# Below is a list of people and organizations that have contributed
# to the V8 project. Names should be added to the list like so:
#
# Name/Organization <email address>
......@@ -82,6 +82,7 @@ JunHo Seo <sejunho@gmail.com>
Kang-Hao (Kenny) Lu <kennyluck@csail.mit.edu>
Karl Skomski <karl@skomski.com>
Kevin Gibbons <bakkot@gmail.com>
Loo Rong Jie <loorongjie@gmail.com>
Luis Reis <luis.m.reis@gmail.com>
Luke Zarko <lukezarko@gmail.com>
Maciej Małecki <me@mmalecki.com>
......
......@@ -1548,6 +1548,61 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
JSObject::AddProperty(global_object,
factory->NewStringFromAsciiChecked("parseInt"),
parse_int_fun, DONT_ENUM);
// Install Number constants
double kMaxValue = 1.7976931348623157e+308;
double kMinValue = 5e-324;
double kMaxSafeInt = 9007199254740991;
double kMinSafeInt = -9007199254740991;
double kEPS = 2.220446049250313e-16;
Handle<Object> infinity = factory->infinity_value();
Handle<Object> nan = factory->nan_value();
Handle<String> nan_name = factory->NewStringFromAsciiChecked("NaN");
JSObject::AddProperty(
number_fun, factory->NewStringFromAsciiChecked("MAX_VALUE"),
factory->NewNumber(kMaxValue),
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
JSObject::AddProperty(
number_fun, factory->NewStringFromAsciiChecked("MIN_VALUE"),
factory->NewNumber(kMinValue),
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
JSObject::AddProperty(
number_fun, nan_name, nan,
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
JSObject::AddProperty(
number_fun, factory->NewStringFromAsciiChecked("NEGATIVE_INFINITY"),
factory->NewNumber(-V8_INFINITY),
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
JSObject::AddProperty(
number_fun, factory->NewStringFromAsciiChecked("POSITIVE_INFINITY"),
infinity,
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
JSObject::AddProperty(
number_fun, factory->NewStringFromAsciiChecked("MAX_SAFE_INTEGER"),
factory->NewNumber(kMaxSafeInt),
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
JSObject::AddProperty(
number_fun, factory->NewStringFromAsciiChecked("MIN_SAFE_INTEGER"),
factory->NewNumber(kMinSafeInt),
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
JSObject::AddProperty(
number_fun, factory->NewStringFromAsciiChecked("EPSILON"),
factory->NewNumber(kEPS),
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
JSObject::AddProperty(
global, factory->NewStringFromAsciiChecked("Infinity"), infinity,
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
JSObject::AddProperty(
global, nan_name, nan,
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
JSObject::AddProperty(
global, factory->NewStringFromAsciiChecked("undefined"),
factory->undefined_value(),
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
}
{ // --- B o o l e a n ---
......
......@@ -9,7 +9,6 @@
// ----------------------------------------------------------------------------
// Imports
var GlobalNumber = global.Number;
var GlobalObject = global.Object;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var NaN = %GetRootNaN();
......@@ -21,15 +20,6 @@ var ObjectToString = utils.ImportNow("object_to_string");
// Set up global object.
var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
utils.InstallConstants(global, [
// ES6 18.1.1
"Infinity", INFINITY,
// ES6 18.1.2
"NaN", NaN,
// ES6 18.1.3
"undefined", UNDEFINED,
]);
// ----------------------------------------------------------------------------
// Object
......@@ -96,29 +86,6 @@ utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
]);
// ----------------------------------------------------------------------------
// Number
utils.InstallConstants(GlobalNumber, [
// ECMA-262 section 15.7.3.1.
"MAX_VALUE", 1.7976931348623157e+308,
// ECMA-262 section 15.7.3.2.
"MIN_VALUE", 5e-324,
// ECMA-262 section 15.7.3.3.
"NaN", NaN,
// ECMA-262 section 15.7.3.4.
"NEGATIVE_INFINITY", -INFINITY,
// ECMA-262 section 15.7.3.5.
"POSITIVE_INFINITY", INFINITY,
// --- Harmony constants (no spec refs until settled.)
"MAX_SAFE_INTEGER", 9007199254740991,
"MIN_SAFE_INTEGER", -9007199254740991,
"EPSILON", 2.220446049250313e-16,
]);
// ----------------------------------------------------------------------------
// Iterator related spec functions.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment