Commit 82f7b654 authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[baseline] Use LocalIsolate in BaselineCompiler

This is useful to guarantee that the compiler can be run off-thread.

- Changes BaselineCompiler isolate_ private member type.
- Constructor still depends on Isolate, since it needs to construct
a MacroAssembler reference.

Bug: v8:12054
Change-Id: Ie7d18b8eb2d0b81a05713ce48d117f92796f2cde
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3085276
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76204}
parent 3f1de995
...@@ -269,7 +269,7 @@ std::unique_ptr<AssemblerBuffer> AllocateBuffer( ...@@ -269,7 +269,7 @@ std::unique_ptr<AssemblerBuffer> AllocateBuffer(
BaselineCompiler::BaselineCompiler( BaselineCompiler::BaselineCompiler(
Isolate* isolate, Handle<SharedFunctionInfo> shared_function_info, Isolate* isolate, Handle<SharedFunctionInfo> shared_function_info,
Handle<BytecodeArray> bytecode, CodeLocation code_location) Handle<BytecodeArray> bytecode, CodeLocation code_location)
: isolate_(isolate), : local_isolate_(isolate->AsLocalIsolate()),
stats_(isolate->counters()->runtime_call_stats()), stats_(isolate->counters()->runtime_call_stats()),
shared_function_info_(shared_function_info), shared_function_info_(shared_function_info),
bytecode_(bytecode), bytecode_(bytecode),
...@@ -353,7 +353,7 @@ void BaselineCompiler::StoreRegisterPair(int operand_index, Register val0, ...@@ -353,7 +353,7 @@ void BaselineCompiler::StoreRegisterPair(int operand_index, Register val0,
template <typename Type> template <typename Type>
Handle<Type> BaselineCompiler::Constant(int operand_index) { Handle<Type> BaselineCompiler::Constant(int operand_index) {
return Handle<Type>::cast( return Handle<Type>::cast(
iterator().GetConstantForIndexOperand(operand_index, isolate_)); iterator().GetConstantForIndexOperand(operand_index, local_isolate_));
} }
Smi BaselineCompiler::ConstantSmi(int operand_index) { Smi BaselineCompiler::ConstantSmi(int operand_index) {
return iterator().GetConstantAtIndexAsSmi(operand_index); return iterator().GetConstantAtIndexAsSmi(operand_index);
...@@ -2053,7 +2053,7 @@ void BaselineCompiler::VisitSetPendingMessage() { ...@@ -2053,7 +2053,7 @@ void BaselineCompiler::VisitSetPendingMessage() {
BaselineAssembler::ScratchRegisterScope scratch_scope(&basm_); BaselineAssembler::ScratchRegisterScope scratch_scope(&basm_);
Register pending_message = scratch_scope.AcquireScratch(); Register pending_message = scratch_scope.AcquireScratch();
__ Move(pending_message, __ Move(pending_message,
ExternalReference::address_of_pending_message(isolate_)); ExternalReference::address_of_pending_message(local_isolate_));
Register tmp = scratch_scope.AcquireScratch(); Register tmp = scratch_scope.AcquireScratch();
__ Move(tmp, kInterpreterAccumulatorRegister); __ Move(tmp, kInterpreterAccumulatorRegister);
__ Move(kInterpreterAccumulatorRegister, MemOperand(pending_message, 0)); __ Move(kInterpreterAccumulatorRegister, MemOperand(pending_message, 0));
......
...@@ -159,7 +159,7 @@ class BaselineCompiler { ...@@ -159,7 +159,7 @@ class BaselineCompiler {
const interpreter::BytecodeArrayIterator& iterator() { return iterator_; } const interpreter::BytecodeArrayIterator& iterator() { return iterator_; }
Isolate* isolate_; LocalIsolate* local_isolate_;
RuntimeCallStats* stats_; RuntimeCallStats* stats_;
Handle<SharedFunctionInfo> shared_function_info_; Handle<SharedFunctionInfo> shared_function_info_;
Handle<BytecodeArray> bytecode_; Handle<BytecodeArray> bytecode_;
......
...@@ -34,7 +34,8 @@ void BaselineCompiler::PrologueFillFrame() { ...@@ -34,7 +34,8 @@ void BaselineCompiler::PrologueFillFrame() {
bytecode_->incoming_new_target_or_generator_register(); bytecode_->incoming_new_target_or_generator_register();
if (FLAG_debug_code) { if (FLAG_debug_code) {
__ masm()->Cmp(kInterpreterAccumulatorRegister, __ masm()->Cmp(kInterpreterAccumulatorRegister,
isolate_->factory()->undefined_value()); handle(ReadOnlyRoots(local_isolate_).undefined_value(),
local_isolate_));
__ masm()->Assert(equal, AbortReason::kUnexpectedValue); __ masm()->Assert(equal, AbortReason::kUnexpectedValue);
} }
int register_count = bytecode_->register_count(); int register_count = bytecode_->register_count();
......
...@@ -497,6 +497,11 @@ ExternalReference ExternalReference::address_of_pending_message( ...@@ -497,6 +497,11 @@ ExternalReference ExternalReference::address_of_pending_message(
return ExternalReference(isolate->pending_message_address()); return ExternalReference(isolate->pending_message_address());
} }
ExternalReference ExternalReference::address_of_pending_message(
LocalIsolate* local_isolate) {
return ExternalReference(local_isolate->pending_message_address());
}
FUNCTION_REFERENCE(abort_with_reason, i::abort_with_reason) FUNCTION_REFERENCE(abort_with_reason, i::abort_with_reason)
ExternalReference ExternalReference::address_of_min_int() { ExternalReference ExternalReference::address_of_min_int() {
......
...@@ -359,6 +359,9 @@ class ExternalReference { ...@@ -359,6 +359,9 @@ class ExternalReference {
EXTERNAL_REFERENCE_LIST_WITH_ISOLATE(COUNT_EXTERNAL_REFERENCE); EXTERNAL_REFERENCE_LIST_WITH_ISOLATE(COUNT_EXTERNAL_REFERENCE);
#undef COUNT_EXTERNAL_REFERENCE #undef COUNT_EXTERNAL_REFERENCE
static V8_EXPORT_PRIVATE ExternalReference
address_of_pending_message(LocalIsolate* local_isolate);
ExternalReference() : address_(kNullAddress) {} ExternalReference() : address_(kNullAddress) {}
static ExternalReference Create(const SCTableReference& table_ref); static ExternalReference Create(const SCTableReference& table_ref);
static ExternalReference Create(StatsCounter* counter); static ExternalReference Create(StatsCounter* counter);
......
...@@ -112,6 +112,10 @@ class V8_EXPORT_PRIVATE LocalIsolate final : private HiddenLocalFactory { ...@@ -112,6 +112,10 @@ class V8_EXPORT_PRIVATE LocalIsolate final : private HiddenLocalFactory {
} }
LocalIsolate* AsLocalIsolate() { return this; } LocalIsolate* AsLocalIsolate() { return this; }
Object* pending_message_address() {
return isolate_->pending_message_address();
}
private: private:
friend class v8::internal::LocalFactory; friend class v8::internal::LocalFactory;
......
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