Commit 641706b4 authored by machenbach's avatar machenbach Committed by Commit bot

Revert of Native context: install array methods via runtime import. (patchset...

Revert of Native context: install array methods via runtime import. (patchset #1 id:1 of https://codereview.chromium.org/1324483002/ )

Reason for revert:
This breaks builds without i18n support. Bisected locally. See builder:

http://build.chromium.org/p/client.v8/builders/V8%20Linux%20-%20noi18n%20-%20debug/builds/4285

http://build.chromium.org/p/client.v8/builders/V8%20Linux%20-%20noi18n%20-%20debug/builds/4285/steps/Check/logs/Threading1

# Fatal error in .././src/objects-inl.h, line 1381
# Check failed: READ_FIELD(this, offset)->IsSmi().

Original issue's description:
> Native context: install array methods via runtime import.
>
> R=cbruni@chromium.org
>
> Committed: https://crrev.com/08ee2132a818a0178038afa521ca06c297195cc9
> Cr-Commit-Position: refs/heads/master@{#30446}

TBR=cbruni@chromium.org,yangguo@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/1314193003

Cr-Commit-Position: refs/heads/master@{#30462}
parent 9987734f
...@@ -11,13 +11,6 @@ ...@@ -11,13 +11,6 @@
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
var ArrayConcatBuiltin = utils.ImportNow("array_concat");
var ArrayPopBuiltin = utils.ImportNow("array_pop");
var ArrayPushBuiltin = utils.ImportNow("array_push");
var ArrayShiftBuiltin = utils.ImportNow("array_shift");
var ArraySliceBuiltin = utils.ImportNow("array_slice");
var ArraySpliceBuiltin = utils.ImportNow("array_splice");
var ArrayUnshiftBuiltin = utils.ImportNow("array_unshift");
var Delete; var Delete;
var GlobalArray = global.Array; var GlobalArray = global.Array;
var InternalArray = utils.InternalArray; var InternalArray = utils.InternalArray;
...@@ -532,7 +525,7 @@ function ArrayPush() { ...@@ -532,7 +525,7 @@ function ArrayPush() {
// Returns an array containing the array elements of the object followed // Returns an array containing the array elements of the object followed
// by the array elements of each argument in order. See ECMA-262, // by the array elements of each argument in order. See ECMA-262,
// section 15.4.4.7. // section 15.4.4.7.
function ArrayConcat(arg1) { // length == 1 function ArrayConcatJS(arg1) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.concat"); CHECK_OBJECT_COERCIBLE(this, "Array.prototype.concat");
var array = TO_OBJECT(this); var array = TO_OBJECT(this);
...@@ -1626,43 +1619,45 @@ utils.InstallFunctions(GlobalArray, DONT_ENUM, [ ...@@ -1626,43 +1619,45 @@ utils.InstallFunctions(GlobalArray, DONT_ENUM, [
"isArray", ArrayIsArray "isArray", ArrayIsArray
]); ]);
var specialFunctions = %SpecialArrayFunctions();
%FunctionSetLength(ArrayEvery, 1); var getFunction = function(name, jsBuiltin, len) {
%FunctionSetLength(ArrayFilter, 1); var f = jsBuiltin;
%FunctionSetLength(ArrayForEach, 1); if (specialFunctions.hasOwnProperty(name)) {
%FunctionSetLength(ArrayIndexOf, 1); f = specialFunctions[name];
%FunctionSetLength(ArrayLastIndexOf, 1); }
%FunctionSetLength(ArrayMap, 1); if (!IS_UNDEFINED(len)) {
%FunctionSetLength(ArrayReduce, 1); %FunctionSetLength(f, len);
%FunctionSetLength(ArrayReduceRight, 1); }
%FunctionSetLength(ArraySome, 1); return f;
};
// Set up non-enumerable functions of the Array.prototype object and // Set up non-enumerable functions of the Array.prototype object and
// set their names. // set their names.
// Manipulate the length of some of the functions to meet // Manipulate the length of some of the functions to meet
// expectations set by ECMA-262 or Mozilla. // expectations set by ECMA-262 or Mozilla.
utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"concat", ArrayConcatBuiltin, "toString", getFunction("toString", ArrayToString),
"every", ArrayEvery, "toLocaleString", getFunction("toLocaleString", ArrayToLocaleString),
"filter", ArrayFilter, "join", getFunction("join", ArrayJoin),
"forEach", ArrayForEach, "pop", getFunction("pop", ArrayPop),
"indexOf", ArrayIndexOf, "push", getFunction("push", ArrayPush, 1),
"join", ArrayJoin, "concat", getFunction("concat", ArrayConcatJS, 1),
"lastIndexOf", ArrayLastIndexOf, "reverse", getFunction("reverse", ArrayReverse),
"map", ArrayMap, "shift", getFunction("shift", ArrayShift),
"pop", ArrayPopBuiltin, "unshift", getFunction("unshift", ArrayUnshift, 1),
"push", ArrayPushBuiltin, "slice", getFunction("slice", ArraySlice, 2),
"reduce", ArrayReduce, "splice", getFunction("splice", ArraySplice, 2),
"reduceRight", ArrayReduceRight, "sort", getFunction("sort", ArraySort),
"reverse", ArrayReverse, "filter", getFunction("filter", ArrayFilter, 1),
"shift", ArrayShiftBuiltin, "forEach", getFunction("forEach", ArrayForEach, 1),
"slice", ArraySliceBuiltin, "some", getFunction("some", ArraySome, 1),
"some", ArraySome, "every", getFunction("every", ArrayEvery, 1),
"sort", ArraySort, "map", getFunction("map", ArrayMap, 1),
"splice", ArraySpliceBuiltin, "indexOf", getFunction("indexOf", ArrayIndexOf, 1),
"toLocaleString", ArrayToLocaleString, "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1),
"toString", ArrayToString, "reduce", getFunction("reduce", ArrayReduce, 1),
"unshift", ArrayUnshiftBuiltin, "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1)
]); ]);
%FinishArrayPrototypeSetup(GlobalArray.prototype); %FinishArrayPrototypeSetup(GlobalArray.prototype);
...@@ -1671,20 +1666,20 @@ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [ ...@@ -1671,20 +1666,20 @@ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
// exposed to user code. // exposed to user code.
// Adding only the functions that are actually used. // Adding only the functions that are actually used.
utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [ utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [
"concat", ArrayConcatBuiltin, "concat", getFunction("concat", ArrayConcatJS),
"indexOf", ArrayIndexOf, "indexOf", getFunction("indexOf", ArrayIndexOf),
"join", ArrayJoin, "join", getFunction("join", ArrayJoin),
"pop", ArrayPopBuiltin, "pop", getFunction("pop", ArrayPop),
"push", ArrayPushBuiltin, "push", getFunction("push", ArrayPush),
"shift", ArrayShiftBuiltin, "shift", getFunction("shift", ArrayShift),
"splice", ArraySpliceBuiltin, "splice", getFunction("splice", ArraySplice)
]); ]);
utils.SetUpLockedPrototype(InternalPackedArray, GlobalArray(), [ utils.SetUpLockedPrototype(InternalPackedArray, GlobalArray(), [
"join", ArrayJoin, "join", getFunction("join", ArrayJoin),
"pop", ArrayPopBuiltin, "pop", getFunction("pop", ArrayPop),
"push", ArrayPushBuiltin, "push", getFunction("push", ArrayPush),
"shift", ArrayShiftBuiltin, "shift", getFunction("shift", ArrayShift)
]); ]);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -1711,7 +1706,7 @@ utils.Export(function(to) { ...@@ -1711,7 +1706,7 @@ utils.Export(function(to) {
}); });
%InstallToContext([ %InstallToContext([
"array_concat", ArrayConcat, "array_concat", ArrayConcatJS,
"array_pop", ArrayPop, "array_pop", ArrayPop,
"array_push", ArrayPush, "array_push", ArrayPush,
"array_shift", ArrayShift, "array_shift", ArrayShift,
......
This diff is collapsed.
...@@ -28,6 +28,35 @@ RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { ...@@ -28,6 +28,35 @@ RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) {
} }
static void InstallBuiltin(Isolate* isolate, Handle<JSObject> holder,
const char* name, Builtins::Name builtin_name) {
Handle<String> key = isolate->factory()->InternalizeUtf8String(name);
Handle<Code> code(isolate->builtins()->builtin(builtin_name));
Handle<JSFunction> optimized =
isolate->factory()->NewFunctionWithoutPrototype(key, code);
optimized->shared()->DontAdaptArguments();
JSObject::AddProperty(holder, key, optimized, NONE);
}
RUNTIME_FUNCTION(Runtime_SpecialArrayFunctions) {
HandleScope scope(isolate);
DCHECK(args.length() == 0);
Handle<JSObject> holder =
isolate->factory()->NewJSObject(isolate->object_function());
InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop);
InstallBuiltin(isolate, holder, "push", Builtins::kArrayPush);
InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift);
InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift);
InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice);
InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice);
InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat);
return *holder;
}
RUNTIME_FUNCTION(Runtime_FixedArrayGet) { RUNTIME_FUNCTION(Runtime_FixedArrayGet) {
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
DCHECK(args.length() == 2); DCHECK(args.length() == 2);
......
...@@ -32,6 +32,7 @@ namespace internal { ...@@ -32,6 +32,7 @@ namespace internal {
#define FOR_EACH_INTRINSIC_ARRAY(F) \ #define FOR_EACH_INTRINSIC_ARRAY(F) \
F(FinishArrayPrototypeSetup, 1, 1) \ F(FinishArrayPrototypeSetup, 1, 1) \
F(SpecialArrayFunctions, 0, 1) \
F(TransitionElementsKind, 2, 1) \ F(TransitionElementsKind, 2, 1) \
F(PushIfAbsent, 2, 1) \ F(PushIfAbsent, 2, 1) \
F(ArrayConcat, 1, 1) \ F(ArrayConcat, 1, 1) \
......
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