Commit 90cb0144 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[ia32,root] Make remainining builtins isolate-independent

Drive-by: Fix ExternalReferenceAddressAsOperand. Now it correctly
returns an operand to within the external reference table.

Bug: v8:6666
Change-Id: I8226257f27a2747584d37fd948d66c6e9b0d7ecf
Reviewed-on: https://chromium-review.googlesource.com/c/1286671
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56739}
parent 3539d6d5
...@@ -327,7 +327,6 @@ bool Builtins::IsLazyDeserializer(Code* code) { ...@@ -327,7 +327,6 @@ bool Builtins::IsLazyDeserializer(Code* code) {
// static // static
bool Builtins::IsIsolateIndependent(int index) { bool Builtins::IsIsolateIndependent(int index) {
DCHECK(IsBuiltinId(index)); DCHECK(IsBuiltinId(index));
#ifndef V8_TARGET_ARCH_IA32
switch (index) { switch (index) {
// TODO(jgruber): There's currently two blockers for moving // TODO(jgruber): There's currently two blockers for moving
// InterpreterEntryTrampoline into the binary: // InterpreterEntryTrampoline into the binary:
...@@ -346,30 +345,6 @@ bool Builtins::IsIsolateIndependent(int index) { ...@@ -346,30 +345,6 @@ bool Builtins::IsIsolateIndependent(int index) {
default: default:
return true; return true;
} }
#else // V8_TARGET_ARCH_IA32
// TODO(jgruber, v8:6666): Implement support.
// ia32 is a work-in-progress. This will let us make builtins
// isolate-independent one-by-one.
switch (index) {
case kCallApiCallback_Argc0:
case kCallApiCallback_Argc1:
case kCallApiGetter:
case kCEntry_Return1_DontSaveFPRegs_ArgvInRegister_NoBuiltinExit:
case kCEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit:
case kCEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit:
case kCEntry_Return1_SaveFPRegs_ArgvOnStack_BuiltinExit:
case kCEntry_Return1_SaveFPRegs_ArgvOnStack_NoBuiltinExit:
case kCEntry_Return2_DontSaveFPRegs_ArgvInRegister_NoBuiltinExit:
case kCEntry_Return2_DontSaveFPRegs_ArgvOnStack_BuiltinExit:
case kCEntry_Return2_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit:
case kCEntry_Return2_SaveFPRegs_ArgvOnStack_BuiltinExit:
case kCEntry_Return2_SaveFPRegs_ArgvOnStack_NoBuiltinExit:
case kInterpreterEntryTrampoline:
return false;
default:
return true;
}
#endif // V8_TARGET_ARCH_IA32
UNREACHABLE(); UNREACHABLE();
} }
......
...@@ -229,14 +229,14 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm, ...@@ -229,14 +229,14 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
Label profiler_disabled; Label profiler_disabled;
Label end_profiler_check; Label end_profiler_check;
__ mov(eax, Immediate(ExternalReference::is_profiling_address(isolate))); __ Move(eax, Immediate(ExternalReference::is_profiling_address(isolate)));
__ cmpb(Operand(eax, 0), Immediate(0)); __ cmpb(Operand(eax, 0), Immediate(0));
__ j(zero, &profiler_disabled); __ j(zero, &profiler_disabled);
// Additional parameter is the address of the actual getter function. // Additional parameter is the address of the actual getter function.
__ mov(thunk_last_arg, function_address); __ mov(thunk_last_arg, function_address);
// Call the api function. // Call the api function.
__ mov(eax, Immediate(thunk_ref)); __ Move(eax, Immediate(thunk_ref));
__ call(eax); __ call(eax);
__ jmp(&end_profiler_check); __ jmp(&end_profiler_check);
...@@ -282,8 +282,8 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm, ...@@ -282,8 +282,8 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
// Check if the function scheduled an exception. // Check if the function scheduled an exception.
ExternalReference scheduled_exception_address = ExternalReference scheduled_exception_address =
ExternalReference::scheduled_exception_address(isolate); ExternalReference::scheduled_exception_address(isolate);
__ cmp(__ ExternalReferenceAsOperand(scheduled_exception_address, ecx), __ mov(ecx, __ ExternalReferenceAsOperand(scheduled_exception_address, ecx));
Immediate(isolate->factory()->the_hole_value())); __ CompareRoot(ecx, RootIndex::kTheHoleValue);
__ j(not_equal, &promote_scheduled_exception); __ j(not_equal, &promote_scheduled_exception);
#if DEBUG #if DEBUG
...@@ -301,19 +301,19 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm, ...@@ -301,19 +301,19 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ CmpInstanceType(map, FIRST_JS_RECEIVER_TYPE); __ CmpInstanceType(map, FIRST_JS_RECEIVER_TYPE);
__ j(above_equal, &ok, Label::kNear); __ j(above_equal, &ok, Label::kNear);
__ cmp(map, isolate->factory()->heap_number_map()); __ CompareRoot(map, RootIndex::kHeapNumberMap);
__ j(equal, &ok, Label::kNear); __ j(equal, &ok, Label::kNear);
__ cmp(return_value, isolate->factory()->undefined_value()); __ CompareRoot(return_value, RootIndex::kUndefinedValue);
__ j(equal, &ok, Label::kNear); __ j(equal, &ok, Label::kNear);
__ cmp(return_value, isolate->factory()->true_value()); __ CompareRoot(return_value, RootIndex::kTrueValue);
__ j(equal, &ok, Label::kNear); __ j(equal, &ok, Label::kNear);
__ cmp(return_value, isolate->factory()->false_value()); __ CompareRoot(return_value, RootIndex::kFalseValue);
__ j(equal, &ok, Label::kNear); __ j(equal, &ok, Label::kNear);
__ cmp(return_value, isolate->factory()->null_value()); __ CompareRoot(return_value, RootIndex::kNullValue);
__ j(equal, &ok, Label::kNear); __ j(equal, &ok, Label::kNear);
__ Abort(AbortReason::kAPICallReturnedInvalidObject); __ Abort(AbortReason::kAPICallReturnedInvalidObject);
...@@ -340,9 +340,9 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm, ...@@ -340,9 +340,9 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ bind(&delete_allocated_handles); __ bind(&delete_allocated_handles);
__ mov(__ ExternalReferenceAsOperand(limit_address, ecx), edi); __ mov(__ ExternalReferenceAsOperand(limit_address, ecx), edi);
__ mov(edi, eax); __ mov(edi, eax);
__ mov(Operand(esp, 0), __ Move(eax, Immediate(ExternalReference::isolate_address(isolate)));
Immediate(ExternalReference::isolate_address(isolate))); __ mov(Operand(esp, 0), eax);
__ mov(eax, Immediate(delete_extensions)); __ Move(eax, Immediate(delete_extensions));
__ call(eax); __ call(eax);
__ mov(eax, edi); __ mov(eax, edi);
__ jmp(&leave_exit_frame); __ jmp(&leave_exit_frame);
...@@ -392,7 +392,7 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) { ...@@ -392,7 +392,7 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
// return value default // return value default
__ PushRoot(RootIndex::kUndefinedValue); __ PushRoot(RootIndex::kUndefinedValue);
// isolate // isolate
__ push(Immediate(ExternalReference::isolate_address(isolate()))); __ Push(Immediate(ExternalReference::isolate_address(isolate())));
// holder // holder
__ push(holder); __ push(holder);
...@@ -466,7 +466,7 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) { ...@@ -466,7 +466,7 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) {
__ PushRoot(RootIndex::kUndefinedValue); // ReturnValue __ PushRoot(RootIndex::kUndefinedValue); // ReturnValue
// ReturnValue default value // ReturnValue default value
__ PushRoot(RootIndex::kUndefinedValue); __ PushRoot(RootIndex::kUndefinedValue);
__ push(Immediate(ExternalReference::isolate_address(isolate()))); __ Push(Immediate(ExternalReference::isolate_address(isolate())));
__ push(holder); __ push(holder);
__ push(Immediate(Smi::kZero)); // should_throw_on_error -> false __ push(Immediate(Smi::kZero)); // should_throw_on_error -> false
__ push(FieldOperand(callback, AccessorInfo::kNameOffset)); __ push(FieldOperand(callback, AccessorInfo::kNameOffset));
......
...@@ -246,8 +246,14 @@ Operand TurboAssembler::ExternalReferenceAddressAsOperand( ...@@ -246,8 +246,14 @@ Operand TurboAssembler::ExternalReferenceAddressAsOperand(
DCHECK(ShouldGenerateIsolateIndependentCode()); DCHECK(ShouldGenerateIsolateIndependentCode());
Assembler::AllowExplicitEbxAccessScope read_only_access(this); Assembler::AllowExplicitEbxAccessScope read_only_access(this);
// Encode as an index into the external reference table stored on the
// isolate.
ExternalReferenceEncoder encoder(isolate());
ExternalReferenceEncoder::Value v = encoder.Encode(reference.address());
CHECK(!v.is_from_api());
return Operand(kRootRegister, return Operand(kRootRegister,
RootRegisterOffsetForExternalReference(isolate(), reference)); RootRegisterOffsetForExternalReferenceIndex(v.index()));
} }
void TurboAssembler::LoadFromConstantsTable(Register destination, void TurboAssembler::LoadFromConstantsTable(Register destination,
...@@ -871,7 +877,8 @@ void MacroAssembler::EnterExitFramePrologue(StackFrame::Type frame_type, ...@@ -871,7 +877,8 @@ void MacroAssembler::EnterExitFramePrologue(StackFrame::Type frame_type,
DCHECK_EQ(-2 * kPointerSize, ExitFrameConstants::kSPOffset); DCHECK_EQ(-2 * kPointerSize, ExitFrameConstants::kSPOffset);
push(Immediate(0)); // Saved entry sp, patched before call. push(Immediate(0)); // Saved entry sp, patched before call.
DCHECK_EQ(-3 * kPointerSize, ExitFrameConstants::kCodeOffset); DCHECK_EQ(-3 * kPointerSize, ExitFrameConstants::kCodeOffset);
push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot. Move(scratch, CodeObject());
push(scratch); // Accessed from ExitFrame::code_slot.
STATIC_ASSERT(edx == kRuntimeCallFunctionRegister); STATIC_ASSERT(edx == kRuntimeCallFunctionRegister);
STATIC_ASSERT(esi == kContextRegister); STATIC_ASSERT(esi == kContextRegister);
......
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