Skip to content

Commit

Permalink
[sfi] Remove DebugInfo field in SharedFunctionInfo.
Browse files Browse the repository at this point in the history
Merges DebugInfo field into the function_identifier field, storing the function
identifier in the DebugInfo. Also moves some debugging_hints bits to the SFI flags,
and others to the DebugInfo. Finally, changes the logic to store debugger patched
bytecode array on the SFI instead of the DebugInfo, simplifying the logic in the
InterpreterEntryTrampoline.

BUG=chromium:818642,chromium:783853
TBR=hpayer@chromium.org

Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: If440080c0f08fac4fb96f5e18dcc0eb9b86d4821
Reviewed-on: https://chromium-review.googlesource.com/1115819
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54081}
  • Loading branch information
rmcilroy authored and Commit Bot committed Jun 28, 2018
1 parent edef59c commit c51bcd1
Show file tree
Hide file tree
Showing 30 changed files with 397 additions and 572 deletions.
19 changes: 8 additions & 11 deletions src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9595,7 +9595,9 @@ void debug::ResetBlackboxedStateCache(Isolate* v8_isolate,
i::SharedFunctionInfo::ScriptIterator iter(isolate,
*Utils::OpenHandle(*script));
while (i::SharedFunctionInfo* info = iter.Next()) {
info->set_computed_debug_is_blackboxed(false);
if (info->HasDebugInfo()) {
info->GetDebugInfo()->set_computed_debug_is_blackboxed(false);
}
}
}

Expand Down Expand Up @@ -9841,16 +9843,11 @@ int64_t debug::GetNextRandomInt64(v8::Isolate* v8_isolate) {
}

int debug::GetDebuggingId(v8::Local<v8::Function> function) {
i::JSReceiver* callable = *v8::Utils::OpenHandle(*function);
if (!callable->IsJSFunction()) return i::SharedFunctionInfo::kNoDebuggingId;
i::JSFunction* fun = i::JSFunction::cast(callable);
i::SharedFunctionInfo* shared = fun->shared();
int id = shared->debugging_id();
if (id == i::SharedFunctionInfo::kNoDebuggingId) {
id = callable->GetHeap()->NextDebuggingId();
shared->set_debugging_id(id);
}
DCHECK_NE(i::SharedFunctionInfo::kNoDebuggingId, id);
i::Handle<i::JSReceiver> callable = v8::Utils::OpenHandle(*function);
if (!callable->IsJSFunction()) return i::DebugInfo::kNoDebuggingId;
i::Handle<i::JSFunction> func = i::Handle<i::JSFunction>::cast(callable);
int id = func->GetIsolate()->debug()->GetFunctionDebuggingId(func);
DCHECK_NE(i::DebugInfo::kNoDebuggingId, id);
return id;
}

Expand Down
40 changes: 2 additions & 38 deletions src/builtins/arm/builtins-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -829,17 +829,12 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
FrameScope frame_scope(masm, StackFrame::MANUAL);
__ PushStandardFrame(closure);

// Get the bytecode array from the function object (or from the DebugInfo if
// it is present) and load it into kInterpreterBytecodeArrayRegister.
Label maybe_load_debug_bytecode_array, bytecode_array_loaded;
// Get the bytecode array from the function object and load it into
// kInterpreterBytecodeArrayRegister.
__ ldr(r0, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
__ ldr(kInterpreterBytecodeArrayRegister,
FieldMemOperand(r0, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, r4);
__ ldr(r4, FieldMemOperand(r0, SharedFunctionInfo::kDebugInfoOffset));
__ SmiTst(r4);
__ b(ne, &maybe_load_debug_bytecode_array);
__ bind(&bytecode_array_loaded);

// Increment invocation count for the function.
__ ldr(r9, FieldMemOperand(feedback_vector,
Expand Down Expand Up @@ -950,37 +945,6 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// The return value is in r0.
LeaveInterpreterFrame(masm, r2);
__ Jump(lr);

// Load debug copy of the bytecode array if it exists.
// kInterpreterBytecodeArrayRegister is already loaded with
// SharedFunctionInfo::kFunctionDataOffset.
__ bind(&maybe_load_debug_bytecode_array);
__ ldr(r9, FieldMemOperand(r4, DebugInfo::kDebugBytecodeArrayOffset), ne);
__ JumpIfRoot(r9, Heap::kUndefinedValueRootIndex, &bytecode_array_loaded);

__ mov(kInterpreterBytecodeArrayRegister, r9);
__ ldr(r9, FieldMemOperand(r4, DebugInfo::kFlagsOffset));
__ SmiUntag(r9);
__ And(r9, r9, Operand(DebugInfo::kDebugExecutionMode));

ExternalReference debug_execution_mode =
ExternalReference::debug_execution_mode_address(masm->isolate());
__ mov(r4, Operand(debug_execution_mode));
__ ldrsb(r4, MemOperand(r4));
STATIC_ASSERT(static_cast<int>(DebugInfo::kDebugExecutionMode) ==
static_cast<int>(DebugInfo::kSideEffects));
__ cmp(r4, r9);
__ b(eq, &bytecode_array_loaded);

__ push(closure);
__ push(feedback_vector);
__ push(kInterpreterBytecodeArrayRegister);
__ push(closure);
__ CallRuntime(Runtime::kDebugApplyInstrumentation);
__ pop(kInterpreterBytecodeArrayRegister);
__ pop(feedback_vector);
__ pop(closure);
__ b(&bytecode_array_loaded);
}

static void Generate_InterpreterPushArgs(MacroAssembler* masm,
Expand Down
35 changes: 3 additions & 32 deletions src/builtins/arm64/builtins-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -901,10 +901,9 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ Push(lr, fp, cp, closure);
__ Add(fp, sp, StandardFrameConstants::kFixedFrameSizeFromFp);

// Get the bytecode array from the function object (or from the DebugInfo if
// it is present) and load it into kInterpreterBytecodeArrayRegister.
Label maybe_load_debug_bytecode_array, bytecode_array_loaded,
has_bytecode_array;
// Get the bytecode array from the function object and load it into
// kInterpreterBytecodeArrayRegister.
Label has_bytecode_array;
__ Ldr(x0, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
__ Ldr(kInterpreterBytecodeArrayRegister,
FieldMemOperand(x0, SharedFunctionInfo::kFunctionDataOffset));
Expand All @@ -915,9 +914,6 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
FieldMemOperand(kInterpreterBytecodeArrayRegister,
InterpreterData::kBytecodeArrayOffset));
__ Bind(&has_bytecode_array);
__ Ldr(x11, FieldMemOperand(x0, SharedFunctionInfo::kDebugInfoOffset));
__ JumpIfNotSmi(x11, &maybe_load_debug_bytecode_array);
__ Bind(&bytecode_array_loaded);

// Increment invocation count for the function.
__ Ldr(x11, FieldMemOperand(closure, JSFunction::kFeedbackCellOffset));
Expand Down Expand Up @@ -1030,31 +1026,6 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// The return value is in x0.
LeaveInterpreterFrame(masm, x2);
__ Ret();

// Load debug copy of the bytecode array if it exists.
// kInterpreterBytecodeArrayRegister is already loaded with
// SharedFunctionInfo::kFunctionDataOffset.
__ Bind(&maybe_load_debug_bytecode_array);
__ Ldr(x10, FieldMemOperand(x11, DebugInfo::kDebugBytecodeArrayOffset));
__ JumpIfRoot(x10, Heap::kUndefinedValueRootIndex, &bytecode_array_loaded);

__ Mov(kInterpreterBytecodeArrayRegister, x10);
__ SmiUntag(x10, FieldMemOperand(x11, DebugInfo::kFlagsOffset));
__ And(x10, x10, Immediate(DebugInfo::kDebugExecutionMode));

STATIC_ASSERT(static_cast<int>(DebugInfo::kDebugExecutionMode) ==
static_cast<int>(DebugInfo::kSideEffects));
ExternalReference debug_execution_mode =
ExternalReference::debug_execution_mode_address(masm->isolate());
__ Mov(x11, Operand(debug_execution_mode));
__ Ldrsb(x11, MemOperand(x11));
__ CompareAndBranch(x10, x11, eq, &bytecode_array_loaded);

__ Push(closure, feedback_vector);
__ PushArgument(closure);
__ CallRuntime(Runtime::kDebugApplyInstrumentation);
__ Pop(feedback_vector, closure);
__ jmp(&bytecode_array_loaded);
}

static void Generate_InterpreterPushArgs(MacroAssembler* masm,
Expand Down
9 changes: 6 additions & 3 deletions src/builtins/builtins-internal-gen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,12 @@ TF_BUILTIN(DebugBreakTrampoline, CodeStubAssembler) {
// Check break-at-entry flag on the debug info.
TNode<SharedFunctionInfo> shared =
CAST(LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset));
TNode<Object> maybe_debug_info =
LoadObjectField(shared, SharedFunctionInfo::kDebugInfoOffset);
GotoIf(TaggedIsSmi(maybe_debug_info), &tailcall_to_shared);
TNode<Object> maybe_heap_object_or_smi = LoadObjectField(
shared, SharedFunctionInfo::kFunctionIdentifierOrDebugInfoOffset);
TNode<HeapObject> maybe_debug_info =
TaggedToHeapObject(maybe_heap_object_or_smi, &tailcall_to_shared);
GotoIfNot(HasInstanceType(maybe_debug_info, InstanceType::DEBUG_INFO_TYPE),
&tailcall_to_shared);

{
TNode<DebugInfo> debug_info = CAST(maybe_debug_info);
Expand Down
38 changes: 2 additions & 36 deletions src/builtins/ia32/builtins-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -800,19 +800,14 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ push(esi); // Callee's context.
__ push(edi); // Callee's JS function.

// Get the bytecode array from the function object (or from the DebugInfo if
// it is present) and load it into kInterpreterBytecodeArrayRegister.
Label maybe_load_debug_bytecode_array, bytecode_array_loaded,
apply_instrumentation;
// Get the bytecode array from the function object and load it into
// kInterpreterBytecodeArrayRegister.
__ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
__ mov(kInterpreterBytecodeArrayRegister,
FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset));
__ Push(eax);
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, eax);
__ Pop(eax);
__ JumpIfNotSmi(FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset),
&maybe_load_debug_bytecode_array);
__ bind(&bytecode_array_loaded);

__ inc(FieldOperand(feedback_vector, FeedbackVector::kInvocationCountOffset));

Expand Down Expand Up @@ -921,35 +916,6 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// The return value is in eax.
LeaveInterpreterFrame(masm, ebx, ecx);
__ ret(0);

// Load debug copy of the bytecode array if it exists.
// kInterpreterBytecodeArrayRegister is already loaded with
// SharedFunctionInfo::kFunctionDataOffset.
__ bind(&maybe_load_debug_bytecode_array);
__ mov(eax, FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset));
__ mov(ecx, FieldOperand(eax, DebugInfo::kDebugBytecodeArrayOffset));
__ JumpIfRoot(ecx, Heap::kUndefinedValueRootIndex, &bytecode_array_loaded);

__ mov(kInterpreterBytecodeArrayRegister, ecx);
__ mov(ecx, FieldOperand(eax, DebugInfo::kFlagsOffset));
__ SmiUntag(ecx);
__ and_(ecx, Immediate(DebugInfo::kDebugExecutionMode));
STATIC_ASSERT(static_cast<int>(DebugInfo::kDebugExecutionMode) ==
static_cast<int>(DebugInfo::kSideEffects));
ExternalReference debug_execution_mode =
ExternalReference::debug_execution_mode_address(masm->isolate());
__ cmp(ecx, Operand::StaticVariable(debug_execution_mode));
__ j(equal, &bytecode_array_loaded);

__ pop(ecx); // get JSFunction from stack
__ push(ecx);
__ push(ebx); // preserve feedback_vector and bytecode array register
__ push(kInterpreterBytecodeArrayRegister);
__ push(ecx); // pass function as argument
__ CallRuntime(Runtime::kDebugApplyInstrumentation);
__ pop(kInterpreterBytecodeArrayRegister);
__ pop(ebx);
__ jmp(&bytecode_array_loaded);
}


Expand Down
38 changes: 2 additions & 36 deletions src/builtins/mips/builtins-mips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -804,16 +804,12 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
FrameScope frame_scope(masm, StackFrame::MANUAL);
__ PushStandardFrame(closure);

// Get the bytecode array from the function object (or from the DebugInfo if
// it is present) and load it into kInterpreterBytecodeArrayRegister.
Label maybe_load_debug_bytecode_array, bytecode_array_loaded;
// Get the bytecode array from the function object and load it into
// kInterpreterBytecodeArrayRegister.
__ lw(a0, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
__ lw(kInterpreterBytecodeArrayRegister,
FieldMemOperand(a0, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, t0);
__ lw(t0, FieldMemOperand(a0, SharedFunctionInfo::kDebugInfoOffset));
__ JumpIfNotSmi(t0, &maybe_load_debug_bytecode_array);
__ bind(&bytecode_array_loaded);

// Increment invocation count for the function.
__ lw(t0, FieldMemOperand(feedback_vector,
Expand Down Expand Up @@ -927,36 +923,6 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// The return value is in v0.
LeaveInterpreterFrame(masm, t0);
__ Jump(ra);

// Load debug copy of the bytecode array if it exists.
// kInterpreterBytecodeArrayRegister is already loaded with
// SharedFunctionInfo::kFunctionDataOffset.
__ bind(&maybe_load_debug_bytecode_array);
__ lw(t1, FieldMemOperand(t0, DebugInfo::kDebugBytecodeArrayOffset));
__ JumpIfRoot(t1, Heap::kUndefinedValueRootIndex, &bytecode_array_loaded);

__ mov(kInterpreterBytecodeArrayRegister, t1);
__ lw(t1, FieldMemOperand(t0, DebugInfo::kFlagsOffset));
__ SmiUntag(t1);
__ And(t1, t1, Operand(DebugInfo::kDebugExecutionMode));

ExternalReference debug_execution_mode =
ExternalReference::debug_execution_mode_address(masm->isolate());
__ li(t0, Operand(debug_execution_mode));
__ lb(t0, MemOperand(t0, kLeastSignificantByteInInt32Offset));
STATIC_ASSERT(static_cast<int>(DebugInfo::kDebugExecutionMode) ==
static_cast<int>(DebugInfo::kSideEffects));
__ Branch(&bytecode_array_loaded, eq, t0, Operand(t1));

__ push(closure);
__ push(feedback_vector);
__ push(kInterpreterBytecodeArrayRegister);
__ push(closure);
__ CallRuntime(Runtime::kDebugApplyInstrumentation);
__ pop(kInterpreterBytecodeArrayRegister);
__ pop(feedback_vector);
__ pop(closure);
__ Branch(&bytecode_array_loaded);
}


Expand Down
38 changes: 2 additions & 36 deletions src/builtins/mips64/builtins-mips64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -803,16 +803,12 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
FrameScope frame_scope(masm, StackFrame::MANUAL);
__ PushStandardFrame(closure);

// Get the bytecode array from the function object (or from the DebugInfo if
// it is present) and load it into kInterpreterBytecodeArrayRegister.
Label maybe_load_debug_bytecode_array, bytecode_array_loaded;
// Get the bytecode array from the function object and load it into
// kInterpreterBytecodeArrayRegister.
__ Ld(a0, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
__ Ld(kInterpreterBytecodeArrayRegister,
FieldMemOperand(a0, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, a4);
__ Ld(a4, FieldMemOperand(a0, SharedFunctionInfo::kDebugInfoOffset));
__ JumpIfNotSmi(a4, &maybe_load_debug_bytecode_array);
__ bind(&bytecode_array_loaded);

// Increment invocation count for the function.
__ Lw(a4, FieldMemOperand(feedback_vector,
Expand Down Expand Up @@ -927,36 +923,6 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// The return value is in v0.
LeaveInterpreterFrame(masm, t0);
__ Jump(ra);

// Load debug copy of the bytecode array if it exists.
// kInterpreterBytecodeArrayRegister is already loaded with
// SharedFunctionInfo::kFunctionDataOffset.
__ bind(&maybe_load_debug_bytecode_array);
__ Ld(a5, FieldMemOperand(a4, DebugInfo::kDebugBytecodeArrayOffset));
__ JumpIfRoot(a5, Heap::kUndefinedValueRootIndex, &bytecode_array_loaded);

__ mov(kInterpreterBytecodeArrayRegister, a5);
__ Ld(a5, FieldMemOperand(a4, DebugInfo::kFlagsOffset));
__ SmiUntag(a5);
__ And(a5, a5, Operand(DebugInfo::kDebugExecutionMode));

ExternalReference debug_execution_mode =
ExternalReference::debug_execution_mode_address(masm->isolate());
__ li(a4, Operand(debug_execution_mode));
__ Lb(a4, MemOperand(a4, kLeastSignificantByteInInt32Offset));
STATIC_ASSERT(static_cast<int>(DebugInfo::kDebugExecutionMode) ==
static_cast<int>(DebugInfo::kSideEffects));
__ Branch(&bytecode_array_loaded, eq, a4, Operand(a5));

__ push(closure);
__ push(feedback_vector);
__ push(kInterpreterBytecodeArrayRegister);
__ push(closure);
__ CallRuntime(Runtime::kDebugApplyInstrumentation);
__ pop(kInterpreterBytecodeArrayRegister);
__ pop(feedback_vector);
__ pop(closure);
__ Branch(&bytecode_array_loaded);
}

static void Generate_StackOverflowCheck(MacroAssembler* masm, Register num_args,
Expand Down
35 changes: 2 additions & 33 deletions src/builtins/ppc/builtins-ppc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -830,18 +830,13 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
FrameScope frame_scope(masm, StackFrame::MANUAL);
__ PushStandardFrame(closure);

// Get the bytecode array from the function object (or from the DebugInfo if
// it is present) and load it into kInterpreterBytecodeArrayRegister.
Label maybe_load_debug_bytecode_array, bytecode_array_loaded;
// Get the bytecode array from the function object and load it into
// kInterpreterBytecodeArrayRegister.
__ LoadP(r3, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
// Load original bytecode array or the debug copy.
__ LoadP(kInterpreterBytecodeArrayRegister,
FieldMemOperand(r3, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, r7);
__ LoadP(r7, FieldMemOperand(r3, SharedFunctionInfo::kDebugInfoOffset));
__ TestIfSmi(r7, r0);
__ bne(&maybe_load_debug_bytecode_array, cr0);
__ bind(&bytecode_array_loaded);

// Increment invocation count for the function.
__ LoadWord(
Expand Down Expand Up @@ -963,32 +958,6 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// The return value is in r3.
LeaveInterpreterFrame(masm, r5);
__ blr();

// Load debug copy of the bytecode array if it exists.
// kInterpreterBytecodeArrayRegister is already loaded with
// SharedFunctionInfo::kFunctionDataOffset.
__ bind(&maybe_load_debug_bytecode_array);
__ LoadP(ip, FieldMemOperand(r7, DebugInfo::kDebugBytecodeArrayOffset));
__ JumpIfRoot(ip, Heap::kUndefinedValueRootIndex, &bytecode_array_loaded);

__ mr(kInterpreterBytecodeArrayRegister, ip);
__ LoadP(ip, FieldMemOperand(r7, DebugInfo::kFlagsOffset));
__ SmiUntag(ip);
__ andi(ip, ip, Operand(DebugInfo::kDebugExecutionMode));

ExternalReference debug_execution_mode =
ExternalReference::debug_execution_mode_address(masm->isolate());
__ mov(r7, Operand(debug_execution_mode));
__ lwz(r7, MemOperand(r7));
STATIC_ASSERT(static_cast<int>(DebugInfo::kDebugExecutionMode) ==
static_cast<int>(DebugInfo::kSideEffects));
__ cmp(r7, ip);
__ beq(&bytecode_array_loaded);

__ Push(closure, feedback_vector, kInterpreterBytecodeArrayRegister, closure);
__ CallRuntime(Runtime::kDebugApplyInstrumentation);
__ Pop(closure, feedback_vector, kInterpreterBytecodeArrayRegister);
__ b(&bytecode_array_loaded);
}

static void Generate_StackOverflowCheck(MacroAssembler* masm, Register num_args,
Expand Down
Loading

0 comments on commit c51bcd1

Please sign in to comment.