Commit 7add73d4 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[ia32,root] Port InternalArrayConstructor{,Impl}

Drive-by: Clarify code that initializes the allocation site argument
of ArrayNArgumentsConstructor to undefined. Until now, this was done
in InternalArrayConstructor prior to calling the Impl builtin. But the
allocation site is not part of the Impl interface descriptor and
worked only by chance since we did not clobber the register. Also, the
argument is only needed for the path that calls
ArrayNArgumentsConstructor and can be omitted elsewhere. This CL pulls
initialization to just before the final call.

Bug: v8:6666
Change-Id: I24471ca0291a83dfad7af4cc11d699c8923117ec
Reviewed-on: https://chromium-review.googlesource.com/1235917
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56086}
parent 29fa45ce
......@@ -60,8 +60,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// Run the native code for the InternalArray function called as a normal
// function.
// tail call a stub
__ LoadRoot(r2, RootIndex::kUndefinedValue);
__ Jump(BUILTIN_CODE(masm->isolate(), InternalArrayConstructorImpl),
RelocInfo::CODE_TARGET);
}
......@@ -2569,6 +2567,10 @@ namespace {
void GenerateInternalArrayConstructorCase(MacroAssembler* masm,
ElementsKind kind) {
// Load undefined into the allocation site parameter as required by
// ArrayNArgumentsConstructor.
__ LoadRoot(kJavaScriptCallExtraArg1Register, RootIndex::kUndefinedValue);
__ cmp(r0, Operand(1));
__ Jump(CodeFactory::InternalArrayNoArgumentConstructor(masm->isolate(), kind)
......
......@@ -55,7 +55,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// Run the native code for the InternalArray function called as a normal
// function.
__ LoadRoot(x2, RootIndex::kUndefinedValue);
__ Jump(BUILTIN_CODE(masm->isolate(), InternalArrayConstructorImpl),
RelocInfo::CODE_TARGET);
}
......@@ -3115,6 +3114,9 @@ void GenerateInternalArrayConstructorCase(MacroAssembler* masm,
__ Bind(&n_case);
// N arguments.
// Load undefined into the allocation site parameter as required by
// ArrayNArgumentsConstructor.
__ LoadRoot(kJavaScriptCallExtraArg1Register, RootIndex::kUndefinedValue);
Handle<Code> code = BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor);
__ Jump(code, RelocInfo::CODE_TARGET);
}
......
......@@ -1645,6 +1645,8 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
}
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
Assembler::SupportsRootRegisterScope supports_root_register(masm);
// ----------- S t a t e -------------
// -- eax : argc
// -- esp[0] : return address
......@@ -1654,19 +1656,18 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
if (FLAG_debug_code) {
// Initial map for the builtin InternalArray function should be a map.
__ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset));
__ mov(ecx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset));
// Will both indicate a nullptr and a Smi.
__ test(ebx, Immediate(kSmiTagMask));
__ test(ecx, Immediate(kSmiTagMask));
__ Assert(not_zero,
AbortReason::kUnexpectedInitialMapForInternalArrayFunction);
__ CmpObjectType(ebx, MAP_TYPE, ecx);
__ CmpObjectType(ecx, MAP_TYPE, ecx);
__ Assert(equal,
AbortReason::kUnexpectedInitialMapForInternalArrayFunction);
}
// Run the native code for the InternalArray function called as a normal
// function.
__ mov(ebx, masm->isolate()->factory()->undefined_value());
__ Jump(BUILTIN_CODE(masm->isolate(), InternalArrayConstructorImpl),
RelocInfo::CODE_TARGET);
}
......@@ -2938,7 +2939,10 @@ void GenerateInternalArrayConstructorCase(MacroAssembler* masm,
RelocInfo::CODE_TARGET);
__ bind(&not_one_case);
__ MoveForRootRegisterRefactoring(kJavaScriptCallExtraArg1Register, ebx);
// Load undefined into the allocation site parameter as required by
// ArrayNArgumentsConstructor.
__ mov(kJavaScriptCallExtraArg1Register,
masm->isolate()->factory()->undefined_value());
Handle<Code> code = BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor);
__ Jump(code, RelocInfo::CODE_TARGET);
}
......@@ -2946,6 +2950,8 @@ void GenerateInternalArrayConstructorCase(MacroAssembler* masm,
} // namespace
void Builtins::Generate_InternalArrayConstructorImpl(MacroAssembler* masm) {
Assembler::SupportsRootRegisterScope supports_root_register(masm);
// ----------- S t a t e -------------
// -- eax : argc
// -- edi : constructor
......
......@@ -56,7 +56,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// Run the native code for the InternalArray function called as a normal
// function.
__ LoadRoot(a2, RootIndex::kUndefinedValue);
__ Jump(BUILTIN_CODE(masm->isolate(), InternalArrayConstructorImpl),
RelocInfo::CODE_TARGET);
}
......@@ -2689,6 +2688,10 @@ namespace {
void GenerateInternalArrayConstructorCase(MacroAssembler* masm,
ElementsKind kind) {
// Load undefined into the allocation site parameter as required by
// ArrayNArgumentsConstructor.
__ LoadRoot(kJavaScriptCallExtraArg1Register, RootIndex::kUndefinedValue);
__ Jump(CodeFactory::InternalArrayNoArgumentConstructor(masm->isolate(), kind)
.code(),
RelocInfo::CODE_TARGET, lo, a0, Operand(1));
......
......@@ -56,7 +56,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// Run the native code for the InternalArray function called as a normal
// function.
__ LoadRoot(a2, RootIndex::kUndefinedValue);
__ Jump(BUILTIN_CODE(masm->isolate(), InternalArrayConstructorImpl),
RelocInfo::CODE_TARGET);
}
......@@ -2708,6 +2707,10 @@ namespace {
void GenerateInternalArrayConstructorCase(MacroAssembler* masm,
ElementsKind kind) {
// Load undefined into the allocation site parameter as required by
// ArrayNArgumentsConstructor.
__ LoadRoot(kJavaScriptCallExtraArg1Register, RootIndex::kUndefinedValue);
__ Jump(CodeFactory::InternalArrayNoArgumentConstructor(masm->isolate(), kind)
.code(),
RelocInfo::CODE_TARGET, lo, a0, Operand(1));
......
......@@ -53,8 +53,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// Run the native code for the InternalArray function called as a normal
// function.
// tail call a stub
__ LoadRoot(r5, RootIndex::kUndefinedValue);
__ Jump(BUILTIN_CODE(masm->isolate(), InternalArrayConstructorImpl),
RelocInfo::CODE_TARGET);
}
......@@ -2727,6 +2725,10 @@ namespace {
void GenerateInternalArrayConstructorCase(MacroAssembler* masm,
ElementsKind kind) {
// Load undefined into the allocation site parameter as required by
// ArrayNArgumentsConstructor.
__ LoadRoot(kJavaScriptCallExtraArg1Register, RootIndex::kUndefinedValue);
__ cmpli(r3, Operand(1));
__ Jump(CodeFactory::InternalArrayNoArgumentConstructor(masm->isolate(), kind)
......
......@@ -53,8 +53,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// Run the native code for the InternalArray function called as a normal
// function.
// tail call a stub
__ LoadRoot(r4, RootIndex::kUndefinedValue);
__ Jump(BUILTIN_CODE(masm->isolate(), InternalArrayConstructorImpl),
RelocInfo::CODE_TARGET);
}
......@@ -2717,6 +2715,10 @@ namespace {
void GenerateInternalArrayConstructorCase(MacroAssembler* masm,
ElementsKind kind) {
// Load undefined into the allocation site parameter as required by
// ArrayNArgumentsConstructor.
__ LoadRoot(kJavaScriptCallExtraArg1Register, RootIndex::kUndefinedValue);
__ CmpLogicalP(r2, Operand(1));
__ Jump(CodeFactory::InternalArrayNoArgumentConstructor(masm->isolate(), kind)
......
......@@ -1599,7 +1599,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// Run the native code for the InternalArray function called as a normal
// function.
__ LoadRoot(rbx, RootIndex::kUndefinedValue);
__ Jump(BUILTIN_CODE(masm->isolate(), InternalArrayConstructorImpl),
RelocInfo::CODE_TARGET);
}
......@@ -2772,6 +2771,9 @@ void GenerateInternalArrayConstructorCase(MacroAssembler* masm,
RelocInfo::CODE_TARGET);
__ bind(&not_one_case);
// Load undefined into the allocation site parameter as required by
// ArrayNArgumentsConstructor.
__ LoadRoot(kJavaScriptCallExtraArg1Register, RootIndex::kUndefinedValue);
Handle<Code> code = BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor);
__ Jump(code, RelocInfo::CODE_TARGET);
}
......
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