Revert "[builtins] Port Object.p.toLocaleString to CSA from JS"
This reverts commit ab38b03d1b
.
Reason for revert:
https://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Linux%2064/builds/20480
https://github.com/v8/v8/wiki/Blink-layout-tests
Original change's description:
> [builtins] Port Object.p.toLocaleString to CSA from JS
>
> - Added ObjectPrototypeToLocaleString TFJ
> - Remove v8natives.js
> - Move GetMethod and GetIterator into prologue.js
>
> TBR=adamk@chromium.org
>
> Bug: v8:6005
> Change-Id: I2b5b65892304e62bf64375458f8ffb9473b2c9b7
> Reviewed-on: https://chromium-review.googlesource.com/826479
> Reviewed-by: Peter Wong <peter.wm.wong@gmail.com>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Commit-Queue: Peter Wong <peter.wm.wong@gmail.com>
> Cr-Commit-Position: refs/heads/master@{#50120}
TBR=adamk@chromium.org,peter.wm.wong@gmail.com,jgruber@chromium.org
Change-Id: Ib406a55562735cc4d879d62b76f27edf3f1ed211
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:6005
Reviewed-on: https://chromium-review.googlesource.com/828813
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50123}
This commit is contained in:
parent
867c39f22c
commit
faf8d4dc17
1
BUILD.gn
1
BUILD.gn
@ -583,6 +583,7 @@ action("js2c") {
|
||||
"src/js/macros.py",
|
||||
"src/messages.h",
|
||||
"src/js/prologue.js",
|
||||
"src/js/v8natives.js",
|
||||
"src/js/array.js",
|
||||
"src/js/typedarray.js",
|
||||
"src/js/messages.js",
|
||||
|
@ -1697,10 +1697,11 @@ class CallNew final : public Expression {
|
||||
ZoneList<Expression*>* arguments_;
|
||||
};
|
||||
|
||||
|
||||
// The CallRuntime class does not represent any official JavaScript
|
||||
// language construct. Instead it is used to call a C or JS function
|
||||
// with a set of arguments. This is used from the builtins that are
|
||||
// implemented in JavaScript.
|
||||
// implemented in JavaScript (see "v8natives.js").
|
||||
class CallRuntime final : public Expression {
|
||||
public:
|
||||
ZoneList<Expression*>* arguments() const { return arguments_; }
|
||||
|
@ -1493,8 +1493,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
||||
true);
|
||||
SimpleInstallFunction(isolate->initial_object_prototype(), "hasOwnProperty",
|
||||
Builtins::kObjectPrototypeHasOwnProperty, 1, true);
|
||||
SimpleInstallFunction(isolate->initial_object_prototype(), "toLocaleString",
|
||||
Builtins::kObjectPrototypeToLocaleString, 0, true);
|
||||
SimpleInstallFunction(isolate->initial_object_prototype(),
|
||||
"__lookupGetter__", Builtins::kObjectLookupGetter, 1,
|
||||
true);
|
||||
|
@ -762,8 +762,6 @@ namespace internal {
|
||||
CPP(ObjectPrototypePropertyIsEnumerable) \
|
||||
CPP(ObjectPrototypeGetProto) \
|
||||
CPP(ObjectPrototypeSetProto) \
|
||||
/* ES #sec-object.prototype.tolocalestring */ \
|
||||
TFJ(ObjectPrototypeToLocaleString, 0) \
|
||||
CPP(ObjectSeal) \
|
||||
CPP(ObjectValues) \
|
||||
\
|
||||
|
@ -97,22 +97,6 @@ Node* ObjectBuiltinsAssembler::ConstructDataDescriptor(Node* context,
|
||||
return js_desc;
|
||||
}
|
||||
|
||||
TF_BUILTIN(ObjectPrototypeToLocaleString, CodeStubAssembler) {
|
||||
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
|
||||
Label if_null_or_undefined(this, Label::kDeferred);
|
||||
GotoIf(IsNullOrUndefined(receiver), &if_null_or_undefined);
|
||||
|
||||
TNode<Object> method =
|
||||
CAST(GetProperty(context, receiver, factory()->toString_string()));
|
||||
Return(CallJS(CodeFactory::Call(isolate()), context, method, receiver));
|
||||
|
||||
BIND(&if_null_or_undefined);
|
||||
ThrowTypeError(context, MessageTemplate::kCalledOnNullOrUndefined,
|
||||
"Object.prototype.toLocaleString");
|
||||
}
|
||||
|
||||
TF_BUILTIN(ObjectPrototypeHasOwnProperty, ObjectBuiltinsAssembler) {
|
||||
Node* object = Parameter(Descriptor::kReceiver);
|
||||
Node* key = Parameter(Descriptor::kKey);
|
||||
|
@ -99,42 +99,6 @@ function PostNatives(utils) {
|
||||
utils.PostNatives = UNDEFINED;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Object
|
||||
|
||||
var iteratorSymbol = ImportNow("iterator_symbol");
|
||||
|
||||
// ES6 7.3.9
|
||||
function GetMethod(obj, p) {
|
||||
var func = obj[p];
|
||||
if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED;
|
||||
if (IS_CALLABLE(func)) return func;
|
||||
throw %make_type_error(kCalledNonCallable, typeof func);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Iterator related spec functions.
|
||||
|
||||
// ES6 7.4.1 GetIterator(obj, method)
|
||||
function GetIterator(obj, method) {
|
||||
if (IS_UNDEFINED(method)) {
|
||||
method = obj[iteratorSymbol];
|
||||
}
|
||||
if (!IS_CALLABLE(method)) {
|
||||
throw %make_type_error(kNotIterable, obj);
|
||||
}
|
||||
var iterator = %_Call(method, obj);
|
||||
if (!IS_RECEIVER(iterator)) {
|
||||
throw %make_type_error(kNotAnIterator, iterator);
|
||||
}
|
||||
return iterator;
|
||||
}
|
||||
|
||||
|
||||
exports_container.GetIterator = GetIterator;
|
||||
exports_container.GetMethod = GetMethod;
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
%OptimizeObjectForAddingMultipleProperties(utils, 14);
|
||||
|
64
src/js/v8natives.js
Normal file
64
src/js/v8natives.js
Normal file
@ -0,0 +1,64 @@
|
||||
// Copyright 2012 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
(function(global, utils) {
|
||||
|
||||
"use strict";
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var GlobalObject = global.Object;
|
||||
var iteratorSymbol = utils.ImportNow("iterator_symbol");
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Object
|
||||
|
||||
// Set up non-enumerable functions on the Object.prototype object.
|
||||
DEFINE_METHOD(
|
||||
GlobalObject.prototype,
|
||||
// ES6 19.1.3.5 Object.prototype.toLocaleString([reserved1 [,reserved2]])
|
||||
toLocaleString() {
|
||||
REQUIRE_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString");
|
||||
return this.toString();
|
||||
}
|
||||
);
|
||||
|
||||
// ES6 7.3.9
|
||||
function GetMethod(obj, p) {
|
||||
var func = obj[p];
|
||||
if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED;
|
||||
if (IS_CALLABLE(func)) return func;
|
||||
throw %make_type_error(kCalledNonCallable, typeof func);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Iterator related spec functions.
|
||||
|
||||
// ES6 7.4.1 GetIterator(obj, method)
|
||||
function GetIterator(obj, method) {
|
||||
if (IS_UNDEFINED(method)) {
|
||||
method = obj[iteratorSymbol];
|
||||
}
|
||||
if (!IS_CALLABLE(method)) {
|
||||
throw %make_type_error(kNotIterable, obj);
|
||||
}
|
||||
var iterator = %_Call(method, obj);
|
||||
if (!IS_RECEIVER(iterator)) {
|
||||
throw %make_type_error(kNotAnIterator, iterator);
|
||||
}
|
||||
return iterator;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Exports
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.GetIterator = GetIterator;
|
||||
to.GetMethod = GetMethod;
|
||||
});
|
||||
|
||||
})
|
@ -2354,6 +2354,7 @@
|
||||
'js/macros.py',
|
||||
'messages.h',
|
||||
'js/prologue.js',
|
||||
'js/v8natives.js',
|
||||
'js/array.js',
|
||||
'js/typedarray.js',
|
||||
'js/messages.js',
|
||||
|
@ -122,10 +122,9 @@ struct StartupBlobs {
|
||||
|
||||
static StartupBlobs Serialize(v8::Isolate* isolate) {
|
||||
// We have to create one context. One reason for this is so that the builtins
|
||||
// can be loaded from self hosted JS builtins and their addresses can be
|
||||
// processed. This will clear the pending fixups array, which would otherwise
|
||||
// contain GC roots that would confuse the serialization/deserialization
|
||||
// process.
|
||||
// can be loaded from v8natives.js and their addresses can be processed. This
|
||||
// will clear the pending fixups array, which would otherwise contain GC roots
|
||||
// that would confuse the serialization/deserialization process.
|
||||
v8::Isolate::Scope isolate_scope(isolate);
|
||||
{
|
||||
v8::HandleScope scope(isolate);
|
||||
|
Loading…
Reference in New Issue
Block a user