Commit f93b27e6 authored by loorongjie's avatar loorongjie Committed by Commit bot

Migrate Object.prototype.valueOf to CSA

BUG=v8:6005

Review-Url: https://codereview.chromium.org/2724833002
Cr-Commit-Position: refs/heads/master@{#43539}
parent f662ae97
...@@ -1270,6 +1270,10 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1270,6 +1270,10 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
SimpleInstallFunction(object_function, factory->values_string(), SimpleInstallFunction(object_function, factory->values_string(),
Builtins::kObjectValues, 1, false); Builtins::kObjectValues, 1, false);
Handle<JSFunction> object_value_of = SimpleInstallFunction(
isolate->initial_object_prototype(), "valueOf",
Builtins::kObjectPrototypeValueOf, 0, true);
native_context()->set_object_value_of(*object_value_of);
SimpleInstallFunction(isolate->initial_object_prototype(), SimpleInstallFunction(isolate->initial_object_prototype(),
"__defineGetter__", Builtins::kObjectDefineGetter, 2, "__defineGetter__", Builtins::kObjectDefineGetter, 2,
true); true);
......
...@@ -310,6 +310,17 @@ TF_BUILTIN(ObjectProtoToString, ObjectBuiltinsAssembler) { ...@@ -310,6 +310,17 @@ TF_BUILTIN(ObjectProtoToString, ObjectBuiltinsAssembler) {
} }
} }
// ES6 19.3.7 Object.prototype.valueOf
TF_BUILTIN(ObjectPrototypeValueOf, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Callable to_object = CodeFactory::ToObject(isolate());
receiver = CallStub(to_object, context, receiver);
Return(receiver);
}
TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) { TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
Node* prototype = Parameter(1); Node* prototype = Parameter(1);
Node* properties = Parameter(2); Node* properties = Parameter(2);
......
...@@ -633,6 +633,7 @@ class Isolate; ...@@ -633,6 +633,7 @@ class Isolate;
CPP(ObjectPreventExtensions) \ CPP(ObjectPreventExtensions) \
/* ES6 section 19.1.3.6 Object.prototype.toString () */ \ /* ES6 section 19.1.3.6 Object.prototype.toString () */ \
TFJ(ObjectProtoToString, 0) \ TFJ(ObjectProtoToString, 0) \
TFJ(ObjectPrototypeValueOf, 0) \
CPP(ObjectPrototypePropertyIsEnumerable) \ CPP(ObjectPrototypePropertyIsEnumerable) \
CPP(ObjectPrototypeGetProto) \ CPP(ObjectPrototypeGetProto) \
CPP(ObjectPrototypeSetProto) \ CPP(ObjectPrototypeSetProto) \
......
...@@ -261,7 +261,7 @@ namespace { ...@@ -261,7 +261,7 @@ namespace {
bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) { bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
switch (id) { switch (id) {
// Whitelist for intrinsics amd runtime functions. // Whitelist for intrinsics and runtime functions.
// Conversions. // Conversions.
case Runtime::kToInteger: case Runtime::kToInteger:
case Runtime::kInlineToInteger: case Runtime::kInlineToInteger:
...@@ -405,6 +405,8 @@ bool BytecodeHasNoSideEffect(interpreter::Bytecode bytecode) { ...@@ -405,6 +405,8 @@ bool BytecodeHasNoSideEffect(interpreter::Bytecode bytecode) {
bool BuiltinHasNoSideEffect(Builtins::Name id) { bool BuiltinHasNoSideEffect(Builtins::Name id) {
switch (id) { switch (id) {
// Whitelist for builtins. // Whitelist for builtins.
// Object builtins.
case Builtins::kObjectPrototypeValueOf:
// Array builtins. // Array builtins.
case Builtins::kArrayCode: case Builtins::kArrayCode:
case Builtins::kArrayIndexOf: case Builtins::kArrayIndexOf:
......
...@@ -30,12 +30,6 @@ function ObjectToLocaleString() { ...@@ -30,12 +30,6 @@ function ObjectToLocaleString() {
} }
// ES6 19.1.3.7 Object.prototype.valueOf()
function ObjectValueOf() {
return TO_OBJECT(this);
}
// ES6 19.1.3.3 Object.prototype.isPrototypeOf(V) // ES6 19.1.3.3 Object.prototype.isPrototypeOf(V)
function ObjectIsPrototypeOf(V) { function ObjectIsPrototypeOf(V) {
if (!IS_RECEIVER(V)) return false; if (!IS_RECEIVER(V)) return false;
...@@ -75,7 +69,7 @@ function ObjectConstructor(x) { ...@@ -75,7 +69,7 @@ function ObjectConstructor(x) {
utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
"toString", ObjectToString, "toString", ObjectToString,
"toLocaleString", ObjectToLocaleString, "toLocaleString", ObjectToLocaleString,
"valueOf", ObjectValueOf, // valueOf is added in bootstrapper.cc.
"isPrototypeOf", ObjectIsPrototypeOf, "isPrototypeOf", ObjectIsPrototypeOf,
// propertyIsEnumerable is added in bootstrapper.cc. // propertyIsEnumerable is added in bootstrapper.cc.
// __defineGetter__ is added in bootstrapper.cc. // __defineGetter__ is added in bootstrapper.cc.
...@@ -112,8 +106,4 @@ utils.Export(function(to) { ...@@ -112,8 +106,4 @@ utils.Export(function(to) {
to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty; to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty;
}); });
%InstallToContext([
"object_value_of", ObjectValueOf,
]);
}) })
...@@ -868,7 +868,7 @@ TEST(CustomSnapshotDataBlobWithWarmup) { ...@@ -868,7 +868,7 @@ TEST(CustomSnapshotDataBlobWithWarmup) {
CHECK(IsCompiled("Math.abs")); CHECK(IsCompiled("Math.abs"));
CHECK(!IsCompiled("g")); CHECK(!IsCompiled("g"));
CHECK(!IsCompiled("String.raw")); CHECK(!IsCompiled("String.raw"));
CHECK(!IsCompiled("Object.valueOf")); CHECK(!IsCompiled("Array.prototype.sort"));
CHECK_EQ(5, CompileRun("a")->Int32Value(context).FromJust()); CHECK_EQ(5, CompileRun("a")->Int32Value(context).FromJust());
} }
isolate->Dispose(); isolate->Dispose();
......
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