Commit 1849b47c authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[ia32,root] Make more builtins isolate-independent

This bundles a bunch of miscellaneous things to make more builtins
isolate-independent (e.g.: using tasm::Move instead of asm::mov
methods).

Drive-by: The isolate-independence whitelist was changed to a blacklist.

Bug: v8:6666
Change-Id: I7e0fbe8bb2ca3dc751ad070f1a92aebb88b43125
Reviewed-on: https://chromium-review.googlesource.com/c/1286331Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56728}
parent 6f218934
This diff is collapsed.
...@@ -883,7 +883,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -883,7 +883,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// If ok, push undefined as the initial value for all register file entries. // If ok, push undefined as the initial value for all register file entries.
Label loop_header; Label loop_header;
Label loop_check; Label loop_check;
__ mov(eax, Immediate(masm->isolate()->factory()->undefined_value())); __ Move(eax, masm->isolate()->factory()->undefined_value());
__ jmp(&loop_check); __ jmp(&loop_check);
__ bind(&loop_header); __ bind(&loop_header);
// TODO(rmcilroy): Consider doing more than one push per loop iteration. // TODO(rmcilroy): Consider doing more than one push per loop iteration.
...@@ -914,9 +914,9 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -914,9 +914,9 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// handler at the current bytecode offset. // handler at the current bytecode offset.
Label do_dispatch; Label do_dispatch;
__ bind(&do_dispatch); __ bind(&do_dispatch);
__ mov(kInterpreterDispatchTableRegister, __ Move(kInterpreterDispatchTableRegister,
Immediate(ExternalReference::interpreter_dispatch_table_address( Immediate(ExternalReference::interpreter_dispatch_table_address(
masm->isolate()))); masm->isolate())));
__ movzx_b(ecx, Operand(kInterpreterBytecodeArrayRegister, __ movzx_b(ecx, Operand(kInterpreterBytecodeArrayRegister,
kInterpreterBytecodeOffsetRegister, times_1, 0)); kInterpreterBytecodeOffsetRegister, times_1, 0));
__ mov( __ mov(
...@@ -1140,10 +1140,11 @@ void Builtins::Generate_InterpreterPushArgsThenConstructImpl( ...@@ -1140,10 +1140,11 @@ void Builtins::Generate_InterpreterPushArgsThenConstructImpl(
__ Pop(kJavaScriptCallNewTargetRegister); __ Pop(kJavaScriptCallNewTargetRegister);
__ Pop(kJavaScriptCallTargetRegister); __ Pop(kJavaScriptCallTargetRegister);
__ PushReturnAddressFrom(eax); __ PushReturnAddressFrom(eax);
__ movd(eax, xmm0); // Reload number of arguments.
__ AssertFunction(kJavaScriptCallTargetRegister); __ AssertFunction(kJavaScriptCallTargetRegister);
__ AssertUndefinedOrAllocationSite(kJavaScriptCallExtraArg1Register); __ AssertUndefinedOrAllocationSite(kJavaScriptCallExtraArg1Register, eax);
__ movd(eax, xmm0); // Reload number of arguments.
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl), __ Jump(BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl),
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
} else if (mode == InterpreterPushArgsMode::kWithFinalSpread) { } else if (mode == InterpreterPushArgsMode::kWithFinalSpread) {
...@@ -1209,9 +1210,9 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) { ...@@ -1209,9 +1210,9 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
__ push(scratch); __ push(scratch);
// Initialize the dispatch table register. // Initialize the dispatch table register.
__ mov(kInterpreterDispatchTableRegister, __ Move(kInterpreterDispatchTableRegister,
Immediate(ExternalReference::interpreter_dispatch_table_address( Immediate(ExternalReference::interpreter_dispatch_table_address(
masm->isolate()))); masm->isolate())));
// Get the bytecode array pointer from the frame. // Get the bytecode array pointer from the frame.
__ mov(kInterpreterBytecodeArrayRegister, __ mov(kInterpreterBytecodeArrayRegister,
...@@ -2154,17 +2155,23 @@ void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) { ...@@ -2154,17 +2155,23 @@ void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) {
// -- edi : the target to call (can be any Object). // -- edi : the target to call (can be any Object).
// ----------------------------------- // -----------------------------------
Label non_callable, non_function, non_smi; Label non_callable, non_function, non_smi, non_jsfunction,
non_jsboundfunction;
__ JumpIfSmi(edi, &non_callable); __ JumpIfSmi(edi, &non_callable);
__ bind(&non_smi); __ bind(&non_smi);
__ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
__ j(equal, masm->isolate()->builtins()->CallFunction(mode), __ j(not_equal, &non_jsfunction);
RelocInfo::CODE_TARGET); __ Jump(masm->isolate()->builtins()->CallFunction(mode),
RelocInfo::CODE_TARGET);
__ bind(&non_jsfunction);
__ CmpInstanceType(ecx, JS_BOUND_FUNCTION_TYPE); __ CmpInstanceType(ecx, JS_BOUND_FUNCTION_TYPE);
__ j(equal, BUILTIN_CODE(masm->isolate(), CallBoundFunction), __ j(not_equal, &non_jsboundfunction);
RelocInfo::CODE_TARGET); __ Jump(BUILTIN_CODE(masm->isolate(), CallBoundFunction),
RelocInfo::CODE_TARGET);
// Check if target is a proxy and call CallProxy external builtin // Check if target is a proxy and call CallProxy external builtin
__ bind(&non_jsboundfunction);
__ test_b(FieldOperand(ecx, Map::kBitFieldOffset), __ test_b(FieldOperand(ecx, Map::kBitFieldOffset),
Immediate(Map::IsCallableBit::kMask)); Immediate(Map::IsCallableBit::kMask));
__ j(zero, &non_callable); __ j(zero, &non_callable);
...@@ -2265,27 +2272,31 @@ void Builtins::Generate_Construct(MacroAssembler* masm) { ...@@ -2265,27 +2272,31 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
// ----------------------------------- // -----------------------------------
// Check if target is a Smi. // Check if target is a Smi.
Label non_constructor, non_proxy; Label non_constructor, non_proxy, non_jsfunction, non_jsboundfunction;
__ JumpIfSmi(edi, &non_constructor, Label::kNear); __ JumpIfSmi(edi, &non_constructor);
// Check if target has a [[Construct]] internal method. // Check if target has a [[Construct]] internal method.
__ mov(ecx, FieldOperand(edi, HeapObject::kMapOffset)); __ mov(ecx, FieldOperand(edi, HeapObject::kMapOffset));
__ test_b(FieldOperand(ecx, Map::kBitFieldOffset), __ test_b(FieldOperand(ecx, Map::kBitFieldOffset),
Immediate(Map::IsConstructorBit::kMask)); Immediate(Map::IsConstructorBit::kMask));
__ j(zero, &non_constructor, Label::kNear); __ j(zero, &non_constructor);
// Dispatch based on instance type. // Dispatch based on instance type.
__ CmpInstanceType(ecx, JS_FUNCTION_TYPE); __ CmpInstanceType(ecx, JS_FUNCTION_TYPE);
__ j(equal, BUILTIN_CODE(masm->isolate(), ConstructFunction), __ j(not_equal, &non_jsfunction);
RelocInfo::CODE_TARGET); __ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction),
RelocInfo::CODE_TARGET);
// Only dispatch to bound functions after checking whether they are // Only dispatch to bound functions after checking whether they are
// constructors. // constructors.
__ bind(&non_jsfunction);
__ CmpInstanceType(ecx, JS_BOUND_FUNCTION_TYPE); __ CmpInstanceType(ecx, JS_BOUND_FUNCTION_TYPE);
__ j(equal, BUILTIN_CODE(masm->isolate(), ConstructBoundFunction), __ j(not_equal, &non_jsboundfunction);
RelocInfo::CODE_TARGET); __ Jump(BUILTIN_CODE(masm->isolate(), ConstructBoundFunction),
RelocInfo::CODE_TARGET);
// Only dispatch to proxies after checking whether they are constructors. // Only dispatch to proxies after checking whether they are constructors.
__ bind(&non_jsboundfunction);
__ CmpInstanceType(ecx, JS_PROXY_TYPE); __ CmpInstanceType(ecx, JS_PROXY_TYPE);
__ j(not_equal, &non_proxy); __ j(not_equal, &non_proxy);
__ Jump(BUILTIN_CODE(masm->isolate(), ConstructProxy), __ Jump(BUILTIN_CODE(masm->isolate(), ConstructProxy),
...@@ -2383,7 +2394,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { ...@@ -2383,7 +2394,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
Label fill; Label fill;
__ bind(&fill); __ bind(&fill);
__ inc(eax); __ inc(eax);
__ push(Immediate(masm->isolate()->factory()->undefined_value())); __ Push(Immediate(masm->isolate()->factory()->undefined_value()));
__ cmp(eax, kExpectedNumberOfArgumentsRegister); __ cmp(eax, kExpectedNumberOfArgumentsRegister);
__ j(less, &fill); __ j(less, &fill);
...@@ -2602,7 +2613,7 @@ void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size, ...@@ -2602,7 +2613,7 @@ void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
// Call C function. // Call C function.
__ mov(Operand(esp, 0 * kPointerSize), edi); // argc. __ mov(Operand(esp, 0 * kPointerSize), edi); // argc.
__ mov(Operand(esp, 1 * kPointerSize), esi); // argv. __ mov(Operand(esp, 1 * kPointerSize), esi); // argv.
__ mov(ecx, Immediate(ExternalReference::isolate_address(masm->isolate()))); __ Move(ecx, Immediate(ExternalReference::isolate_address(masm->isolate())));
__ mov(Operand(esp, 2 * kPointerSize), ecx); __ mov(Operand(esp, 2 * kPointerSize), ecx);
__ call(kRuntimeCallFunctionRegister); __ call(kRuntimeCallFunctionRegister);
...@@ -2610,14 +2621,14 @@ void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size, ...@@ -2610,14 +2621,14 @@ void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
// Check result for exception sentinel. // Check result for exception sentinel.
Label exception_returned; Label exception_returned;
__ cmp(eax, masm->isolate()->factory()->exception()); __ CompareRoot(eax, RootIndex::kException);
__ j(equal, &exception_returned); __ j(equal, &exception_returned);
// Check that there is no pending exception, otherwise we // Check that there is no pending exception, otherwise we
// should have returned the exception sentinel. // should have returned the exception sentinel.
if (FLAG_debug_code) { if (FLAG_debug_code) {
__ push(edx); __ push(edx);
__ mov(edx, Immediate(masm->isolate()->factory()->the_hole_value())); __ LoadRoot(edx, RootIndex::kTheHoleValue);
Label okay; Label okay;
ExternalReference pending_exception_address = ExternalReference::Create( ExternalReference pending_exception_address = ExternalReference::Create(
IsolateAddressId::kPendingExceptionAddress, masm->isolate()); IsolateAddressId::kPendingExceptionAddress, masm->isolate());
...@@ -2655,8 +2666,9 @@ void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size, ...@@ -2655,8 +2666,9 @@ void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
__ PrepareCallCFunction(3, eax); __ PrepareCallCFunction(3, eax);
__ mov(Operand(esp, 0 * kPointerSize), Immediate(0)); // argc. __ mov(Operand(esp, 0 * kPointerSize), Immediate(0)); // argc.
__ mov(Operand(esp, 1 * kPointerSize), Immediate(0)); // argv. __ mov(Operand(esp, 1 * kPointerSize), Immediate(0)); // argv.
__ mov(Operand(esp, 2 * kPointerSize), __ Move(esi,
Immediate(ExternalReference::isolate_address(masm->isolate()))); Immediate(ExternalReference::isolate_address(masm->isolate())));
__ mov(Operand(esp, 2 * kPointerSize), esi);
__ CallCFunction(find_handler, 3); __ CallCFunction(find_handler, 3);
} }
...@@ -2959,8 +2971,7 @@ void GenerateInternalArrayConstructorCase(MacroAssembler* masm, ...@@ -2959,8 +2971,7 @@ void GenerateInternalArrayConstructorCase(MacroAssembler* masm,
__ bind(&not_one_case); __ bind(&not_one_case);
// Load undefined into the allocation site parameter as required by // Load undefined into the allocation site parameter as required by
// ArrayNArgumentsConstructor. // ArrayNArgumentsConstructor.
__ mov(kJavaScriptCallExtraArg1Register, __ LoadRoot(kJavaScriptCallExtraArg1Register, RootIndex::kUndefinedValue);
masm->isolate()->factory()->undefined_value());
Handle<Code> code = BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor); Handle<Code> code = BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor);
__ Jump(code, RelocInfo::CODE_TARGET); __ Jump(code, RelocInfo::CODE_TARGET);
} }
......
...@@ -678,7 +678,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -678,7 +678,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
MoveOperandIfAliasedWithPoisonRegister(instr, this); MoveOperandIfAliasedWithPoisonRegister(instr, this);
if (HasImmediateInput(instr, 0)) { if (HasImmediateInput(instr, 0)) {
Handle<Code> code = i.InputCode(0); Handle<Code> code = i.InputCode(0);
__ call(code, RelocInfo::CODE_TARGET); __ Call(code, RelocInfo::CODE_TARGET);
} else { } else {
Register reg = i.InputRegister(0); Register reg = i.InputRegister(0);
DCHECK_IMPLIES( DCHECK_IMPLIES(
...@@ -730,7 +730,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -730,7 +730,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
} }
if (HasImmediateInput(instr, 0)) { if (HasImmediateInput(instr, 0)) {
Handle<Code> code = i.InputCode(0); Handle<Code> code = i.InputCode(0);
__ jmp(code, RelocInfo::CODE_TARGET); __ Jump(code, RelocInfo::CODE_TARGET);
} else { } else {
Register reg = i.InputRegister(0); Register reg = i.InputRegister(0);
DCHECK_IMPLIES( DCHECK_IMPLIES(
......
...@@ -539,12 +539,15 @@ void MacroAssembler::RecordWrite(Register object, Register address, ...@@ -539,12 +539,15 @@ void MacroAssembler::RecordWrite(Register object, Register address,
void MacroAssembler::MaybeDropFrames() { void MacroAssembler::MaybeDropFrames() {
// Check whether we need to drop frames to restart a function on the stack. // Check whether we need to drop frames to restart a function on the stack.
Label dont_drop;
ExternalReference restart_fp = ExternalReference restart_fp =
ExternalReference::debug_restart_fp_address(isolate()); ExternalReference::debug_restart_fp_address(isolate());
mov(eax, ExternalReferenceAsOperand(restart_fp, eax)); mov(eax, ExternalReferenceAsOperand(restart_fp, eax));
test(eax, eax); test(eax, eax);
j(not_zero, BUILTIN_CODE(isolate(), FrameDropperTrampoline), j(zero, &dont_drop, Label::kNear);
RelocInfo::CODE_TARGET);
Jump(BUILTIN_CODE(isolate(), FrameDropperTrampoline), RelocInfo::CODE_TARGET);
bind(&dont_drop);
} }
void TurboAssembler::Cvtsi2ss(XMMRegister dst, Operand src) { void TurboAssembler::Cvtsi2ss(XMMRegister dst, Operand src) {
...@@ -760,14 +763,15 @@ void MacroAssembler::AssertGeneratorObject(Register object) { ...@@ -760,14 +763,15 @@ void MacroAssembler::AssertGeneratorObject(Register object) {
Check(equal, AbortReason::kOperandIsNotAGeneratorObject); Check(equal, AbortReason::kOperandIsNotAGeneratorObject);
} }
void MacroAssembler::AssertUndefinedOrAllocationSite(Register object) { void MacroAssembler::AssertUndefinedOrAllocationSite(Register object,
Register scratch) {
if (emit_debug_code()) { if (emit_debug_code()) {
Label done_checking; Label done_checking;
AssertNotSmi(object); AssertNotSmi(object);
cmp(object, isolate()->factory()->undefined_value()); CompareRoot(object, scratch, RootIndex::kUndefinedValue);
j(equal, &done_checking); j(equal, &done_checking);
cmp(FieldOperand(object, 0), LoadRoot(scratch, RootIndex::kAllocationSiteWithWeakNextMap);
Immediate(isolate()->factory()->allocation_site_map())); cmp(FieldOperand(object, 0), scratch);
Assert(equal, AbortReason::kExpectedUndefinedOrCell); Assert(equal, AbortReason::kExpectedUndefinedOrCell);
bind(&done_checking); bind(&done_checking);
} }
...@@ -1304,7 +1308,7 @@ void MacroAssembler::InvokeFunctionCode(Register function, Register new_target, ...@@ -1304,7 +1308,7 @@ void MacroAssembler::InvokeFunctionCode(Register function, Register new_target,
// Clear the new.target register if not given. // Clear the new.target register if not given.
if (!new_target.is_valid()) { if (!new_target.is_valid()) {
mov(edx, isolate()->factory()->undefined_value()); Move(edx, isolate()->factory()->undefined_value());
} }
Label done; Label done;
...@@ -1380,6 +1384,7 @@ void TurboAssembler::Ret(int bytes_dropped, Register scratch) { ...@@ -1380,6 +1384,7 @@ void TurboAssembler::Ret(int bytes_dropped, Register scratch) {
void TurboAssembler::Push(Immediate value) { void TurboAssembler::Push(Immediate value) {
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
if (root_array_available_ && ShouldGenerateIsolateIndependentCode()) { if (root_array_available_ && ShouldGenerateIsolateIndependentCode()) {
Assembler::AllowExplicitEbxAccessScope read_only_access(this);
if (value.is_embedded_object()) { if (value.is_embedded_object()) {
Push(HeapObjectAsOperand(value.embedded_object())); Push(HeapObjectAsOperand(value.embedded_object()));
return; return;
......
...@@ -660,7 +660,7 @@ class MacroAssembler : public TurboAssembler { ...@@ -660,7 +660,7 @@ class MacroAssembler : public TurboAssembler {
// Abort execution if argument is not undefined or an AllocationSite, enabled // Abort execution if argument is not undefined or an AllocationSite, enabled
// via --debug-code. // via --debug-code.
void AssertUndefinedOrAllocationSite(Register object); void AssertUndefinedOrAllocationSite(Register object, Register scratch);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Exception handling // Exception handling
......
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