[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: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56739}
This commit is contained in:
Jakob Gruber 2018-10-17 15:22:16 +02:00 committed by Commit Bot
parent 3539d6d543
commit 90cb014493
3 changed files with 23 additions and 41 deletions

View File

@ -327,7 +327,6 @@ bool Builtins::IsLazyDeserializer(Code* code) {
// static
bool Builtins::IsIsolateIndependent(int index) {
DCHECK(IsBuiltinId(index));
#ifndef V8_TARGET_ARCH_IA32
switch (index) {
// TODO(jgruber): There's currently two blockers for moving
// InterpreterEntryTrampoline into the binary:
@ -346,30 +345,6 @@ bool Builtins::IsIsolateIndependent(int index) {
default:
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();
}

View File

@ -229,14 +229,14 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
Label profiler_disabled;
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));
__ j(zero, &profiler_disabled);
// Additional parameter is the address of the actual getter function.
__ mov(thunk_last_arg, function_address);
// Call the api function.
__ mov(eax, Immediate(thunk_ref));
__ Move(eax, Immediate(thunk_ref));
__ call(eax);
__ jmp(&end_profiler_check);
@ -282,8 +282,8 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
// Check if the function scheduled an exception.
ExternalReference scheduled_exception_address =
ExternalReference::scheduled_exception_address(isolate);
__ cmp(__ ExternalReferenceAsOperand(scheduled_exception_address, ecx),
Immediate(isolate->factory()->the_hole_value()));
__ mov(ecx, __ ExternalReferenceAsOperand(scheduled_exception_address, ecx));
__ CompareRoot(ecx, RootIndex::kTheHoleValue);
__ j(not_equal, &promote_scheduled_exception);
#if DEBUG
@ -301,19 +301,19 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ CmpInstanceType(map, FIRST_JS_RECEIVER_TYPE);
__ j(above_equal, &ok, Label::kNear);
__ cmp(map, isolate->factory()->heap_number_map());
__ CompareRoot(map, RootIndex::kHeapNumberMap);
__ j(equal, &ok, Label::kNear);
__ cmp(return_value, isolate->factory()->undefined_value());
__ CompareRoot(return_value, RootIndex::kUndefinedValue);
__ j(equal, &ok, Label::kNear);
__ cmp(return_value, isolate->factory()->true_value());
__ CompareRoot(return_value, RootIndex::kTrueValue);
__ j(equal, &ok, Label::kNear);
__ cmp(return_value, isolate->factory()->false_value());
__ CompareRoot(return_value, RootIndex::kFalseValue);
__ j(equal, &ok, Label::kNear);
__ cmp(return_value, isolate->factory()->null_value());
__ CompareRoot(return_value, RootIndex::kNullValue);
__ j(equal, &ok, Label::kNear);
__ Abort(AbortReason::kAPICallReturnedInvalidObject);
@ -340,9 +340,9 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ bind(&delete_allocated_handles);
__ mov(__ ExternalReferenceAsOperand(limit_address, ecx), edi);
__ mov(edi, eax);
__ mov(Operand(esp, 0),
Immediate(ExternalReference::isolate_address(isolate)));
__ mov(eax, Immediate(delete_extensions));
__ Move(eax, Immediate(ExternalReference::isolate_address(isolate)));
__ mov(Operand(esp, 0), eax);
__ Move(eax, Immediate(delete_extensions));
__ call(eax);
__ mov(eax, edi);
__ jmp(&leave_exit_frame);
@ -392,7 +392,7 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
// return value default
__ PushRoot(RootIndex::kUndefinedValue);
// isolate
__ push(Immediate(ExternalReference::isolate_address(isolate())));
__ Push(Immediate(ExternalReference::isolate_address(isolate())));
// holder
__ push(holder);
@ -466,7 +466,7 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) {
__ PushRoot(RootIndex::kUndefinedValue); // ReturnValue
// ReturnValue default value
__ PushRoot(RootIndex::kUndefinedValue);
__ push(Immediate(ExternalReference::isolate_address(isolate())));
__ Push(Immediate(ExternalReference::isolate_address(isolate())));
__ push(holder);
__ push(Immediate(Smi::kZero)); // should_throw_on_error -> false
__ push(FieldOperand(callback, AccessorInfo::kNameOffset));

View File

@ -246,8 +246,14 @@ Operand TurboAssembler::ExternalReferenceAddressAsOperand(
DCHECK(ShouldGenerateIsolateIndependentCode());
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,
RootRegisterOffsetForExternalReference(isolate(), reference));
RootRegisterOffsetForExternalReferenceIndex(v.index()));
}
void TurboAssembler::LoadFromConstantsTable(Register destination,
@ -871,7 +877,8 @@ void MacroAssembler::EnterExitFramePrologue(StackFrame::Type frame_type,
DCHECK_EQ(-2 * kPointerSize, ExitFrameConstants::kSPOffset);
push(Immediate(0)); // Saved entry sp, patched before call.
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(esi == kContextRegister);