Commit ab61093f authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

Reland "[debug] add runtime side effect check for StaCurrentContextSlot"

This is a reland of 0340874b

Original change's description:
> [debug] add runtime side effect check for StaCurrentContextSlot
> 
> R=yangguo@chromium.org
> 
> Bug: v8:7588
> Change-Id: If78f6dd460c7423923800a98d44520c1bf71663c
> Reviewed-on: https://chromium-review.googlesource.com/996236
> Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#52398}

Bug: v8:7588
Change-Id: Ife6b039ea3291103a54ae04c3007fe4610371c3f
Reviewed-on: https://chromium-review.googlesource.com/998801Reviewed-by: 's avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52452}
parent 83fd383b
......@@ -858,6 +858,7 @@ bool BytecodeRequiresRuntimeCheck(interpreter::Bytecode bytecode) {
case Bytecode::kStaKeyedProperty:
case Bytecode::kStaInArrayLiteral:
case Bytecode::kStaDataPropertyInLiteral:
case Bytecode::kStaCurrentContextSlot:
return true;
default:
return false;
......
......@@ -2413,8 +2413,28 @@ bool Debug::PerformSideEffectCheckForCallback(Handle<Object> callback_info) {
return false;
}
bool Debug::PerformSideEffectCheckForObject(Handle<Object> object) {
bool Debug::PerformSideEffectCheckAtBytecode(InterpretedFrame* frame) {
using interpreter::Bytecode;
DCHECK_EQ(isolate_->debug_execution_mode(), DebugInfo::kSideEffects);
SharedFunctionInfo* shared = frame->function()->shared();
BytecodeArray* bytecode_array = shared->bytecode_array();
int offset = frame->GetBytecodeOffset();
interpreter::BytecodeArrayAccessor bytecode_accessor(handle(bytecode_array),
offset);
Bytecode bytecode = bytecode_accessor.current_bytecode();
interpreter::Register reg;
switch (bytecode) {
case Bytecode::kStaCurrentContextSlot:
reg = interpreter::Register::current_context();
break;
default:
reg = bytecode_accessor.GetRegisterOperand(0);
break;
}
Handle<Object> object =
handle(frame->ReadInterpreterRegister(reg.index()), isolate_);
if (object->IsHeapObject()) {
Address address = Handle<HeapObject>::cast(object)->address();
if (temporary_objects_->HasObject(address)) {
......@@ -2422,14 +2442,6 @@ bool Debug::PerformSideEffectCheckForObject(Handle<Object> object) {
}
}
if (FLAG_trace_side_effect_free_debug_evaluate) {
JavaScriptFrameIterator it(isolate_);
InterpretedFrame* interpreted_frame =
reinterpret_cast<InterpretedFrame*>(it.frame());
SharedFunctionInfo* shared = interpreted_frame->function()->shared();
BytecodeArray* bytecode_array = shared->bytecode_array();
int bytecode_offset = interpreted_frame->GetBytecodeOffset();
interpreter::Bytecode bytecode =
interpreter::Bytecodes::FromByte(bytecode_array->get(bytecode_offset));
PrintF("[debug-evaluate] %s failed runtime side effect check.\n",
interpreter::Bytecodes::ToString(bytecode));
}
......
......@@ -347,7 +347,7 @@ class Debug {
bool PerformSideEffectCheck(Handle<JSFunction> function);
bool PerformSideEffectCheckForCallback(Handle<Object> callback_info);
bool PerformSideEffectCheckForObject(Handle<Object> object);
bool PerformSideEffectCheckAtBytecode(InterpretedFrame* frame);
// Flags and states.
DebugScope* debugger_entry() {
......
......@@ -59,15 +59,8 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_DebugBreakOnBytecode) {
bool side_effect_check_failed = false;
if (isolate->debug_execution_mode() == DebugInfo::kSideEffects) {
int offset = interpreted_frame->GetBytecodeOffset();
interpreter::BytecodeArrayAccessor bytecode_accessor(handle(bytecode_array),
offset);
interpreter::Register reg = bytecode_accessor.GetRegisterOperand(0);
Handle<Object> first_operand = handle(
interpreted_frame->ReadInterpreterRegister(reg.index()), isolate);
if (!isolate->debug()->PerformSideEffectCheckForObject(first_operand)) {
side_effect_check_failed = true;
}
side_effect_check_failed =
!isolate->debug()->PerformSideEffectCheckAtBytecode(interpreted_frame);
}
if (Bytecodes::Returns(bytecode)) {
......
......@@ -4,6 +4,13 @@
Debug = debug.Debug;
// StaCurrentContextSlot
success(10, `(function(){
const x = 10;
function f1() {return x;}
return x;
})()`);
// StaNamedProperty
var a = {name: 'foo'};
function set_name(a) {
......
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