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

Unified Diff: src/bootstrapper.cc

Issue 2715793004: Migrate Number constants and undefined to C++ (Closed)
Patch Set: Reuse string Created 3 years, 10 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 | « AUTHORS ('k') | src/js/v8natives.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 8371955a437edd9c020d77771db12bdd4f2058ef..af113d3481413d0fa743fce11db3afdabee2c0d7 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1497,6 +1497,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 ---
« no previous file with comments | « AUTHORS ('k') | src/js/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698