[explicit isolates] Remove GetHeap from CallHandlerInfo
Pass Isolate directly into CallHandlerInfo methods so that calls to GetHeap can be removed. Bug: v8:7786 Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng Change-Id: If28fbbd65530b01b69786c3e743754cff3b1ba3a Reviewed-on: https://chromium-review.googlesource.com/1107926 Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#53945}
This commit is contained in:
parent
b686ca2171
commit
7da6adcb6b
10
src/api.cc
10
src/api.cc
@ -5178,8 +5178,8 @@ MaybeLocal<Object> Function::NewInstanceWithSideEffectType(
|
||||
i::JSFunction::cast(*self)->shared()->get_api_func_data()->call_code();
|
||||
if (obj->IsCallHandlerInfo()) {
|
||||
i::CallHandlerInfo* handler_info = i::CallHandlerInfo::cast(obj);
|
||||
if (!handler_info->IsSideEffectFreeCallHandlerInfo()) {
|
||||
handler_info->SetNextCallHasNoSideEffect();
|
||||
if (!handler_info->IsSideEffectFreeCallHandlerInfo(isolate)) {
|
||||
handler_info->SetNextCallHasNoSideEffect(isolate);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5194,10 +5194,10 @@ MaybeLocal<Object> Function::NewInstanceWithSideEffectType(
|
||||
i::CallHandlerInfo* handler_info = i::CallHandlerInfo::cast(obj);
|
||||
if (has_pending_exception) {
|
||||
// Restore the map if an exception prevented restoration.
|
||||
handler_info->NextCallHasNoSideEffect();
|
||||
handler_info->NextCallHasNoSideEffect(isolate);
|
||||
} else {
|
||||
DCHECK(handler_info->IsSideEffectCallHandlerInfo() ||
|
||||
handler_info->IsSideEffectFreeCallHandlerInfo());
|
||||
DCHECK(handler_info->IsSideEffectCallHandlerInfo(isolate) ||
|
||||
handler_info->IsSideEffectFreeCallHandlerInfo(isolate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -952,7 +952,8 @@ SharedFunctionInfo::SideEffectState DebugEvaluate::FunctionGetSideEffectState(
|
||||
}
|
||||
|
||||
// static
|
||||
bool DebugEvaluate::CallbackHasNoSideEffect(Object* callback_info) {
|
||||
bool DebugEvaluate::CallbackHasNoSideEffect(Isolate* isolate,
|
||||
Object* callback_info) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
if (callback_info->IsAccessorInfo()) {
|
||||
// List of whitelisted internal accessors can be found in accessors.h.
|
||||
@ -971,7 +972,7 @@ bool DebugEvaluate::CallbackHasNoSideEffect(Object* callback_info) {
|
||||
}
|
||||
} else if (callback_info->IsCallHandlerInfo()) {
|
||||
CallHandlerInfo* info = CallHandlerInfo::cast(callback_info);
|
||||
if (info->IsSideEffectFreeCallHandlerInfo()) return true;
|
||||
if (info->IsSideEffectFreeCallHandlerInfo(isolate)) return true;
|
||||
if (FLAG_trace_side_effect_free_debug_evaluate) {
|
||||
PrintF("[debug-evaluate] API CallHandlerInfo may cause side effect.\n");
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class DebugEvaluate : public AllStatic {
|
||||
|
||||
static SharedFunctionInfo::SideEffectState FunctionGetSideEffectState(
|
||||
Isolate* isolate, Handle<SharedFunctionInfo> info);
|
||||
static bool CallbackHasNoSideEffect(Object* callback_info);
|
||||
static bool CallbackHasNoSideEffect(Isolate* isolate, Object* callback_info);
|
||||
static void ApplySideEffectChecks(Handle<BytecodeArray> bytecode_array);
|
||||
|
||||
private:
|
||||
|
@ -2297,12 +2297,13 @@ bool Debug::PerformSideEffectCheck(Handle<JSFunction> function,
|
||||
bool Debug::PerformSideEffectCheckForCallback(Handle<Object> callback_info) {
|
||||
DCHECK_EQ(isolate_->debug_execution_mode(), DebugInfo::kSideEffects);
|
||||
if (!callback_info.is_null() && callback_info->IsCallHandlerInfo() &&
|
||||
i::CallHandlerInfo::cast(*callback_info)->NextCallHasNoSideEffect()) {
|
||||
i::CallHandlerInfo::cast(*callback_info)
|
||||
->NextCallHasNoSideEffect(isolate_)) {
|
||||
return true;
|
||||
}
|
||||
// TODO(7515): always pass a valid callback info object.
|
||||
if (!callback_info.is_null() &&
|
||||
DebugEvaluate::CallbackHasNoSideEffect(*callback_info)) {
|
||||
DebugEvaluate::CallbackHasNoSideEffect(isolate_, *callback_info)) {
|
||||
return true;
|
||||
}
|
||||
side_effect_check_failed_ = true;
|
||||
|
@ -1836,7 +1836,7 @@ void CallHandlerInfo::CallHandlerInfoPrint(std::ostream& os) { // NOLINT
|
||||
os << "\n - js_callback: " << Brief(js_callback());
|
||||
os << "\n - data: " << Brief(data());
|
||||
os << "\n - side_effect_free: "
|
||||
<< (IsSideEffectFreeCallHandlerInfo() ? "true" : "false");
|
||||
<< (IsSideEffectFreeCallHandlerInfo(GetIsolate()) ? "true" : "false");
|
||||
os << "\n";
|
||||
}
|
||||
|
||||
|
@ -3506,7 +3506,7 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
|
||||
os << "callback= " << Brief(info->callback());
|
||||
os << ", js_callback= " << Brief(info->js_callback());
|
||||
os << ", data= " << Brief(info->data());
|
||||
if (info->IsSideEffectFreeCallHandlerInfo()) {
|
||||
if (info->IsSideEffectFreeCallHandlerInfo(isolate)) {
|
||||
os << ", side_effect_free= true>";
|
||||
} else {
|
||||
os << ", side_effect_free= false>";
|
||||
|
@ -101,29 +101,30 @@ ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset)
|
||||
ACCESSORS(CallHandlerInfo, js_callback, Object, kJsCallbackOffset)
|
||||
ACCESSORS(CallHandlerInfo, data, Object, kDataOffset)
|
||||
|
||||
bool CallHandlerInfo::IsSideEffectFreeCallHandlerInfo() const {
|
||||
DCHECK(map() == GetHeap()->side_effect_call_handler_info_map() ||
|
||||
map() == GetHeap()->side_effect_free_call_handler_info_map() ||
|
||||
map() ==
|
||||
GetHeap()->next_call_side_effect_free_call_handler_info_map());
|
||||
return map() == GetHeap()->side_effect_free_call_handler_info_map();
|
||||
bool CallHandlerInfo::IsSideEffectFreeCallHandlerInfo(Isolate* isolate) const {
|
||||
Heap* heap = isolate->heap();
|
||||
DCHECK(map() == heap->side_effect_call_handler_info_map() ||
|
||||
map() == heap->side_effect_free_call_handler_info_map() ||
|
||||
map() == heap->next_call_side_effect_free_call_handler_info_map());
|
||||
return map() == heap->side_effect_free_call_handler_info_map();
|
||||
}
|
||||
|
||||
bool CallHandlerInfo::IsSideEffectCallHandlerInfo() const {
|
||||
DCHECK(map() == GetHeap()->side_effect_call_handler_info_map() ||
|
||||
map() == GetHeap()->side_effect_free_call_handler_info_map() ||
|
||||
map() ==
|
||||
GetHeap()->next_call_side_effect_free_call_handler_info_map());
|
||||
return map() == GetHeap()->side_effect_call_handler_info_map();
|
||||
bool CallHandlerInfo::IsSideEffectCallHandlerInfo(Isolate* isolate) const {
|
||||
Heap* heap = isolate->heap();
|
||||
DCHECK(map() == heap->side_effect_call_handler_info_map() ||
|
||||
map() == heap->side_effect_free_call_handler_info_map() ||
|
||||
map() == heap->next_call_side_effect_free_call_handler_info_map());
|
||||
return map() == heap->side_effect_call_handler_info_map();
|
||||
}
|
||||
|
||||
void CallHandlerInfo::SetNextCallHasNoSideEffect() {
|
||||
set_map(GetHeap()->next_call_side_effect_free_call_handler_info_map());
|
||||
void CallHandlerInfo::SetNextCallHasNoSideEffect(Isolate* isolate) {
|
||||
set_map(isolate->heap()->next_call_side_effect_free_call_handler_info_map());
|
||||
}
|
||||
|
||||
bool CallHandlerInfo::NextCallHasNoSideEffect() {
|
||||
if (map() == GetHeap()->next_call_side_effect_free_call_handler_info_map()) {
|
||||
set_map(GetHeap()->side_effect_call_handler_info_map());
|
||||
bool CallHandlerInfo::NextCallHasNoSideEffect(Isolate* isolate) {
|
||||
Heap* heap = isolate->heap();
|
||||
if (map() == heap->next_call_side_effect_free_call_handler_info_map()) {
|
||||
set_map(heap->side_effect_call_handler_info_map());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -186,12 +186,12 @@ class CallHandlerInfo : public Tuple3 {
|
||||
|
||||
DECL_CAST(CallHandlerInfo)
|
||||
|
||||
inline bool IsSideEffectFreeCallHandlerInfo() const;
|
||||
inline bool IsSideEffectCallHandlerInfo() const;
|
||||
inline void SetNextCallHasNoSideEffect();
|
||||
inline bool IsSideEffectFreeCallHandlerInfo(Isolate* isolate) const;
|
||||
inline bool IsSideEffectCallHandlerInfo(Isolate* isolate) const;
|
||||
inline void SetNextCallHasNoSideEffect(Isolate* isolate);
|
||||
// Returns whether or not the next call can be side effect free.
|
||||
// Calling this will change the state back to having a side effect.
|
||||
inline bool NextCallHasNoSideEffect();
|
||||
inline bool NextCallHasNoSideEffect(Isolate* isolate);
|
||||
|
||||
// Dispatched behavior.
|
||||
DECL_PRINTER(CallHandlerInfo)
|
||||
|
@ -13404,7 +13404,7 @@ TEST(CallHandlerAsFunctionHasNoSideEffectNotSupported) {
|
||||
i::Heap* heap = reinterpret_cast<i::Isolate*>(isolate)->heap();
|
||||
i::CallHandlerInfo* handler_info =
|
||||
i::CallHandlerInfo::cast(cons->instance_call_handler());
|
||||
CHECK(!handler_info->IsSideEffectFreeCallHandlerInfo());
|
||||
CHECK(!handler_info->IsSideEffectFreeCallHandlerInfo(CcTest::i_isolate()));
|
||||
handler_info->set_map(heap->side_effect_free_call_handler_info_map());
|
||||
CHECK(v8::debug::EvaluateGlobal(isolate, v8_str("obj()"), true).IsEmpty());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user