summaryrefslogtreecommitdiff
path: root/chromium/v8/src/isolate.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/v8/src/isolate.cc')
-rw-r--r--chromium/v8/src/isolate.cc397
1 files changed, 259 insertions, 138 deletions
diff --git a/chromium/v8/src/isolate.cc b/chromium/v8/src/isolate.cc
index e3ee968f79a..7165d88d34b 100644
--- a/chromium/v8/src/isolate.cc
+++ b/chromium/v8/src/isolate.cc
@@ -54,7 +54,8 @@
#include "src/visitors.h"
#include "src/vm-state-inl.h"
#include "src/wasm/compilation-manager.h"
-#include "src/wasm/wasm-heap.h"
+#include "src/wasm/wasm-code-manager.h"
+#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-objects.h"
#include "src/zone/accounting-allocator.h"
@@ -109,6 +110,8 @@ void ThreadLocalTop::InitializeInternal() {
rethrowing_message_ = false;
pending_message_obj_ = nullptr;
scheduled_exception_ = nullptr;
+ microtask_queue_bailout_index_ = -1;
+ microtask_queue_bailout_count_ = 0;
}
@@ -332,8 +335,8 @@ void Isolate::PushStackTraceAndDie(unsigned int magic1, void* ptr1, void* ptr2,
"ptr6=%p ptr7=%p ptr8=%p\n\n%s",
magic1, magic2, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7, ptr8,
reinterpret_cast<char*>(buffer));
- PushCodeObjectsAndDie(0xdeadc0de, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7,
- ptr8, 0xdeadc0de);
+ PushCodeObjectsAndDie(0xDEADC0DE, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7,
+ ptr8, 0xDEADC0DE);
}
void Isolate::PushCodeObjectsAndDie(unsigned int magic1, void* ptr1, void* ptr2,
@@ -429,12 +432,12 @@ class FrameArrayBuilder {
//====================================================================
const auto& summary = summ.AsWasmCompiled();
if (!summary.code().IsCodeObject() &&
- summary.code().GetWasmCode()->kind() != wasm::WasmCode::Function) {
+ summary.code().GetWasmCode()->kind() != wasm::WasmCode::kFunction) {
continue;
}
Handle<WasmInstanceObject> instance = summary.wasm_instance();
int flags = 0;
- if (instance->compiled_module()->is_asm_js()) {
+ if (instance->compiled_module()->shared()->is_asm_js()) {
flags |= FrameArray::kIsAsmJsWasmFrame;
if (WasmCompiledFrame::cast(frame)->at_to_number_conversion()) {
flags |= FrameArray::kAsmJsAtNumberConversion;
@@ -453,7 +456,7 @@ class FrameArrayBuilder {
const auto& summary = summ.AsWasmInterpreted();
Handle<WasmInstanceObject> instance = summary.wasm_instance();
int flags = FrameArray::kIsWasmInterpretedFrame;
- DCHECK(!instance->compiled_module()->is_asm_js());
+ DCHECK(!instance->compiled_module()->shared()->is_asm_js());
elements_ = FrameArray::AppendWasmFrame(elements_, instance,
summary.function_index(), {},
summary.byte_offset(), flags);
@@ -667,6 +670,11 @@ Handle<FixedArray> Isolate::GetDetailedStackTrace(
Address Isolate::GetAbstractPC(int* line, int* column) {
JavaScriptFrameIterator it(this);
+ if (it.done()) {
+ *line = -1;
+ *column = -1;
+ return nullptr;
+ }
JavaScriptFrame* frame = it.frame();
DCHECK(!frame->is_builtin());
int position = frame->position();
@@ -764,10 +772,10 @@ class CaptureStackTraceHelper {
const FrameSummary::WasmFrameSummary& summ) {
Handle<StackFrameInfo> info = factory()->NewStackFrameInfo();
- Handle<WasmCompiledModule> compiled_module(
- summ.wasm_instance()->compiled_module(), isolate_);
- Handle<String> name = WasmCompiledModule::GetFunctionName(
- isolate_, compiled_module, summ.function_index());
+ Handle<WasmSharedModuleData> shared(
+ summ.wasm_instance()->compiled_module()->shared(), isolate_);
+ Handle<String> name = WasmSharedModuleData::GetFunctionName(
+ isolate_, shared, summ.function_index());
info->set_function_name(*name);
// Encode the function index as line number (1-based).
info->set_line_number(summ.function_index() + 1);
@@ -1029,7 +1037,7 @@ void Isolate::RequestInterrupt(InterruptCallback callback, void* data) {
void Isolate::InvokeApiInterruptCallbacks() {
RuntimeCallTimerScope runtimeTimer(
- this, &RuntimeCallStats::InvokeApiInterruptCallbacks);
+ this, RuntimeCallCounterId::kInvokeApiInterruptCallbacks);
// Note: callback below should be called outside of execution access lock.
while (true) {
InterruptEntry entry;
@@ -1133,7 +1141,7 @@ Object* Isolate::Throw(Object* exception, MessageLocation* location) {
#ifdef DEBUG
if (AllowHeapAllocation::IsAllowed()) {
#else
- if (false) {
+ if ((false)) {
#endif
printf(", %d:%d - %d:%d\n",
Script::GetLineNumber(script, location->start_pos()) + 1,
@@ -1301,7 +1309,7 @@ Object* Isolate::UnwindAndFindHandler() {
set_wasm_caught_exception(exception);
if (FLAG_wasm_jit_to_native) {
wasm::WasmCode* wasm_code =
- wasm_code_manager()->LookupCode(frame->pc());
+ wasm_engine()->code_manager()->LookupCode(frame->pc());
return FoundHandler(nullptr, wasm_code->instructions().start(),
offset, wasm_code->constant_pool(), return_sp,
frame->fp());
@@ -1683,8 +1691,7 @@ bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target,
for (int i = 0; i < frame_count; i++) {
if (elements->IsWasmFrame(i) || elements->IsAsmJsWasmFrame(i)) {
Handle<WasmCompiledModule> compiled_module(
- WasmInstanceObject::cast(elements->WasmInstance(i))
- ->compiled_module());
+ elements->WasmInstance(i)->compiled_module());
uint32_t func_index =
static_cast<uint32_t>(elements->WasmFunctionIndex(i)->value());
int code_offset = elements->Offset(i)->value();
@@ -1701,9 +1708,10 @@ bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target,
bool is_at_number_conversion =
elements->IsAsmJsWasmFrame(i) &&
elements->Flags(i)->value() & FrameArray::kAsmJsAtNumberConversion;
- int pos = WasmCompiledModule::GetSourcePosition(
- compiled_module, func_index, byte_offset, is_at_number_conversion);
- Handle<Script> script(compiled_module->script());
+ int pos = WasmSharedModuleData::GetSourcePosition(
+ handle(compiled_module->shared(), this), func_index, byte_offset,
+ is_at_number_conversion);
+ Handle<Script> script(compiled_module->shared()->script());
*target = MessageLocation(script, pos, pos + 1);
return true;
@@ -1810,21 +1818,9 @@ bool Isolate::IsExternalHandlerOnTop(Object* exception) {
return (entry_handler > external_handler);
}
-
-void Isolate::ReportPendingMessages() {
- DCHECK(AllowExceptions::IsAllowed(this));
-
- // The embedder might run script in response to an exception.
- AllowJavascriptExecutionDebugOnly allow_script(this);
-
+void Isolate::ReportPendingMessagesImpl(bool report_externally) {
Object* exception = pending_exception();
- // Try to propagate the exception to an external v8::TryCatch handler. If
- // propagation was unsuccessful, then we will get another chance at reporting
- // the pending message if the exception is re-thrown.
- bool has_been_propagated = PropagatePendingExceptionToExternalTryCatch();
- if (!has_been_propagated) return;
-
// Clear the pending message object early to avoid endless recursion.
Object* message_obj = thread_local_top_.pending_message_obj_;
clear_pending_message();
@@ -1837,7 +1833,7 @@ void Isolate::ReportPendingMessages() {
// depending on whether and external v8::TryCatch or an internal JavaScript
// handler is on top.
bool should_report_exception;
- if (IsExternalHandlerOnTop(exception)) {
+ if (report_externally) {
// Only report the exception if the external handler is verbose.
should_report_exception = try_catch_handler()->is_verbose_;
} else {
@@ -1858,6 +1854,85 @@ void Isolate::ReportPendingMessages() {
}
}
+void Isolate::ReportPendingMessages() {
+ DCHECK(AllowExceptions::IsAllowed(this));
+
+ // The embedder might run script in response to an exception.
+ AllowJavascriptExecutionDebugOnly allow_script(this);
+
+ Object* exception = pending_exception();
+
+ // Try to propagate the exception to an external v8::TryCatch handler. If
+ // propagation was unsuccessful, then we will get another chance at reporting
+ // the pending message if the exception is re-thrown.
+ bool has_been_propagated = PropagatePendingExceptionToExternalTryCatch();
+ if (!has_been_propagated) return;
+
+ ReportPendingMessagesImpl(IsExternalHandlerOnTop(exception));
+}
+
+void Isolate::ReportPendingMessagesFromJavaScript() {
+ DCHECK(AllowExceptions::IsAllowed(this));
+
+ auto IsHandledByJavaScript = [=]() {
+ // In this situation, the exception is always a non-terminating exception.
+
+ // Get the top-most JS_ENTRY handler, cannot be on top if it doesn't exist.
+ Address entry_handler = Isolate::handler(thread_local_top());
+ DCHECK_NOT_NULL(entry_handler);
+ entry_handler =
+ reinterpret_cast<StackHandler*>(entry_handler)->next()->address();
+
+ // Get the address of the external handler so we can compare the address to
+ // determine which one is closer to the top of the stack.
+ Address external_handler = thread_local_top()->try_catch_handler_address();
+ if (external_handler == nullptr) return true;
+
+ return (entry_handler < external_handler);
+ };
+
+ auto IsHandledExternally = [=]() {
+ Address external_handler = thread_local_top()->try_catch_handler_address();
+ if (external_handler == nullptr) return false;
+
+ // Get the top-most JS_ENTRY handler, cannot be on top if it doesn't exist.
+ Address entry_handler = Isolate::handler(thread_local_top());
+ DCHECK_NOT_NULL(entry_handler);
+ entry_handler =
+ reinterpret_cast<StackHandler*>(entry_handler)->next()->address();
+ return (entry_handler > external_handler);
+ };
+
+ auto PropagateToExternalHandler = [=]() {
+ if (IsHandledByJavaScript()) {
+ thread_local_top_.external_caught_exception_ = false;
+ return false;
+ }
+
+ if (!IsHandledExternally()) {
+ thread_local_top_.external_caught_exception_ = false;
+ return true;
+ }
+
+ thread_local_top_.external_caught_exception_ = true;
+ v8::TryCatch* handler = try_catch_handler();
+ DCHECK(thread_local_top_.pending_message_obj_->IsJSMessageObject() ||
+ thread_local_top_.pending_message_obj_->IsTheHole(this));
+ handler->can_continue_ = true;
+ handler->has_terminated_ = false;
+ handler->exception_ = pending_exception();
+ // Propagate to the external try-catch only if we got an actual message.
+ if (thread_local_top_.pending_message_obj_->IsTheHole(this)) return true;
+
+ handler->message_obj_ = thread_local_top_.pending_message_obj_;
+ return true;
+ };
+
+ // Try to propagate to an external v8::TryCatch handler.
+ if (!PropagateToExternalHandler()) return;
+
+ ReportPendingMessagesImpl(true);
+}
MessageLocation Isolate::GetMessageLocation() {
DCHECK(has_pending_exception());
@@ -2041,8 +2116,23 @@ Handle<Object> Isolate::GetPromiseOnStackOnThrow() {
}
Handle<Object> retval = undefined;
PromiseOnStack* promise_on_stack = tltop->promise_on_stack_;
- for (JavaScriptFrameIterator it(this); !it.done(); it.Advance()) {
- switch (PredictException(it.frame())) {
+ for (StackFrameIterator it(this); !it.done(); it.Advance()) {
+ StackFrame* frame = it.frame();
+ HandlerTable::CatchPrediction catch_prediction;
+ if (frame->is_java_script()) {
+ catch_prediction = PredictException(JavaScriptFrame::cast(frame));
+ } else if (frame->type() == StackFrame::STUB) {
+ Code* code = frame->LookupCode();
+ if (!code->IsCode() || code->kind() != Code::BUILTIN ||
+ !code->handler_table()->length() || !code->is_turbofanned()) {
+ continue;
+ }
+ catch_prediction = code->GetBuiltinCatchPrediction();
+ } else {
+ continue;
+ }
+
+ switch (catch_prediction) {
case HandlerTable::UNCAUGHT:
continue;
case HandlerTable::CAUGHT:
@@ -2392,9 +2482,9 @@ Isolate::Isolate(bool enable_serializer)
descriptor_lookup_cache_(nullptr),
handle_scope_implementer_(nullptr),
unicode_cache_(nullptr),
- allocator_(FLAG_trace_gc_object_stats ? new VerboseAccountingAllocator(
- &heap_, 256 * KB, 128 * KB)
- : new AccountingAllocator()),
+ allocator_(FLAG_trace_zone_stats ? new VerboseAccountingAllocator(
+ &heap_, 256 * KB, 128 * KB)
+ : new AccountingAllocator()),
inner_pointer_to_code_cache_(nullptr),
global_handles_(nullptr),
eternal_handles_(nullptr),
@@ -2432,7 +2522,6 @@ Isolate::Isolate(bool enable_serializer)
use_counter_callback_(nullptr),
basic_block_profiler_(nullptr),
cancelable_task_manager_(new CancelableTaskManager()),
- wasm_compilation_manager_(new wasm::CompilationManager()),
abort_on_uncaught_exception_callback_(nullptr),
total_regexp_code_generated_(0) {
{
@@ -2454,9 +2543,6 @@ Isolate::Isolate(bool enable_serializer)
thread_manager_->isolate_ = this;
#ifdef DEBUG
- // heap_histograms_ initializes itself.
- memset(&js_spill_information_, 0, sizeof(js_spill_information_));
-
non_disposed_isolates_.Increment(1);
#endif // DEBUG
@@ -2482,6 +2568,10 @@ Isolate::Isolate(bool enable_serializer)
void Isolate::TearDown() {
TRACE_ISOLATE(tear_down);
+ if (FLAG_stress_sampling_allocation_profiler > 0) {
+ heap_profiler()->StopSamplingHeapProfiler();
+ }
+
// Temporarily set this isolate as current so that various parts of
// the isolate can access it in their destructors without having a
// direct pointer. We don't use Enter/Exit here to avoid
@@ -2535,7 +2625,7 @@ void Isolate::Deinit() {
optimizing_compile_dispatcher_ = nullptr;
}
- wasm_compilation_manager_->TearDown();
+ wasm_engine()->compilation_manager()->TearDown();
heap_.mark_compact_collector()->EnsureSweepingCompleted();
heap_.memory_allocator()->unmapper()->WaitUntilCompleted();
@@ -2686,9 +2776,8 @@ Isolate::~Isolate() {
allocator_ = nullptr;
#if USE_SIMULATOR
- Simulator::TearDown(simulator_i_cache_, simulator_redirection_);
+ Simulator::TearDown(simulator_i_cache_);
simulator_i_cache_ = nullptr;
- simulator_redirection_ = nullptr;
#endif
}
@@ -2816,11 +2905,8 @@ bool Isolate::Init(StartupDeserializer* des) {
// Initialize other runtime facilities
#if defined(USE_SIMULATOR)
-#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \
- V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390
Simulator::Initialize(this);
#endif
-#endif
{ // NOLINT
// Ensure that the thread has a valid stack guard. The v8::Locker object
@@ -2837,16 +2923,15 @@ bool Isolate::Init(StartupDeserializer* des) {
return false;
}
- // Setup the wasm code manager. Currently, there's one per Isolate.
- if (!wasm_code_manager_) {
- size_t max_code_size = kMaxWasmCodeMemory;
- if (kRequiresCodeRange) {
- max_code_size = std::min(max_code_size,
- heap_.memory_allocator()->code_range()->size());
- }
- wasm_code_manager_.reset(new wasm::WasmCodeManager(
- reinterpret_cast<v8::Isolate*>(this), max_code_size));
- }
+ // Setup the wasm engine. Currently, there's one per Isolate.
+ const size_t max_code_size =
+ kRequiresCodeRange
+ ? std::min(kMaxWasmCodeMemory,
+ heap_.memory_allocator()->code_range()->size())
+ : kMaxWasmCodeMemory;
+ wasm_engine_.reset(new wasm::WasmEngine(
+ std::unique_ptr<wasm::WasmCodeManager>(new wasm::WasmCodeManager(
+ reinterpret_cast<v8::Isolate*>(this), max_code_size))));
// Initialize the interface descriptors ahead of time.
#define INTERFACE_DESCRIPTOR(Name, ...) \
@@ -2953,6 +3038,15 @@ bool Isolate::Init(StartupDeserializer* des) {
if (!FLAG_inline_new) heap_.DisableInlineAllocation();
+ if (FLAG_stress_sampling_allocation_profiler > 0) {
+ uint64_t sample_interval = FLAG_stress_sampling_allocation_profiler;
+ int stack_depth = 128;
+ v8::HeapProfiler::SamplingFlags sampling_flags =
+ v8::HeapProfiler::SamplingFlags::kSamplingForceGC;
+ heap_profiler()->StartSamplingHeapProfiler(sample_interval, stack_depth,
+ sampling_flags);
+ }
+
return true;
}
@@ -3090,7 +3184,7 @@ bool Isolate::use_optimizer() {
bool Isolate::NeedsSourcePositionsForProfiling() const {
return FLAG_trace_deopt || FLAG_trace_turbo || FLAG_trace_turbo_graph ||
FLAG_turbo_profiling || FLAG_perf_prof || is_profiling() ||
- debug_->is_active() || logger_->is_logging();
+ debug_->is_active() || logger_->is_logging() || FLAG_trace_maps;
}
void Isolate::SetFeedbackVectorsForProfilingTools(Object* value) {
@@ -3098,27 +3192,32 @@ void Isolate::SetFeedbackVectorsForProfilingTools(Object* value) {
heap()->set_feedback_vectors_for_profiling_tools(value);
}
-void Isolate::InitializeVectorListFromHeap() {
+void Isolate::MaybeInitializeVectorListFromHeap() {
+ if (!heap()->feedback_vectors_for_profiling_tools()->IsUndefined(this)) {
+ // Already initialized, return early.
+ DCHECK(heap()->feedback_vectors_for_profiling_tools()->IsArrayList());
+ return;
+ }
+
// Collect existing feedback vectors.
std::vector<Handle<FeedbackVector>> vectors;
+
{
HeapIterator heap_iterator(heap());
while (HeapObject* current_obj = heap_iterator.next()) {
- if (current_obj->IsSharedFunctionInfo()) {
- SharedFunctionInfo* shared = SharedFunctionInfo::cast(current_obj);
- shared->set_has_reported_binary_coverage(false);
- } else if (current_obj->IsFeedbackVector()) {
- FeedbackVector* vector = FeedbackVector::cast(current_obj);
- SharedFunctionInfo* shared = vector->shared_function_info();
- if (!shared->IsSubjectToDebugging()) continue;
- vector->clear_invocation_count();
- vectors.emplace_back(vector, this);
- }
+ if (!current_obj->IsFeedbackVector()) continue;
+
+ FeedbackVector* vector = FeedbackVector::cast(current_obj);
+ SharedFunctionInfo* shared = vector->shared_function_info();
+
+ // No need to preserve the feedback vector for non-user-visible functions.
+ if (!shared->IsSubjectToDebugging()) continue;
+
+ vectors.emplace_back(vector, this);
}
}
- // Add collected feedback vectors to the root list lest we lose them to
- // GC.
+ // Add collected feedback vectors to the root list lest we lose them to GC.
Handle<ArrayList> list =
ArrayList::New(this, static_cast<int>(vectors.size()));
for (const auto& vector : vectors) list = ArrayList::Add(list, vector);
@@ -3356,7 +3455,16 @@ base::RandomNumberGenerator* Isolate::random_number_generator() {
}
base::RandomNumberGenerator* Isolate::fuzzer_rng() {
- return ensure_rng_exists(&fuzzer_rng_, FLAG_fuzzer_random_seed);
+ if (fuzzer_rng_ == nullptr) {
+ int64_t seed = FLAG_fuzzer_random_seed;
+ if (seed == 0) {
+ seed = random_number_generator()->initial_seed();
+ }
+
+ fuzzer_rng_ = new base::RandomNumberGenerator(seed);
+ }
+
+ return fuzzer_rng_;
}
int Isolate::GenerateIdentityHash(uint32_t mask) {
@@ -3688,72 +3796,89 @@ void Isolate::RunMicrotasksInternal() {
if (!pending_microtask_count()) return;
TRACE_EVENT0("v8.execute", "RunMicrotasks");
TRACE_EVENT_CALL_STATS_SCOPED(this, "v8", "V8.RunMicrotasks");
- while (pending_microtask_count() > 0) {
- HandleScope scope(this);
- int num_tasks = pending_microtask_count();
- // Do not use factory()->microtask_queue() here; we need a fresh handle!
- Handle<FixedArray> queue(heap()->microtask_queue(), this);
- DCHECK(num_tasks <= queue->length());
- set_pending_microtask_count(0);
- heap()->set_microtask_queue(heap()->empty_fixed_array());
- Isolate* isolate = this;
- FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < num_tasks, i++, {
- Handle<Object> microtask(queue->get(i), this);
-
- if (microtask->IsCallHandlerInfo()) {
- Handle<CallHandlerInfo> callback_info =
- Handle<CallHandlerInfo>::cast(microtask);
- v8::MicrotaskCallback callback =
- v8::ToCData<v8::MicrotaskCallback>(callback_info->callback());
- void* data = v8::ToCData<void*>(callback_info->data());
- callback(data);
- } else {
- SaveContext save(this);
- Context* context;
- if (microtask->IsJSFunction()) {
- context = Handle<JSFunction>::cast(microtask)->context();
- } else if (microtask->IsPromiseResolveThenableJobInfo()) {
- context =
- Handle<PromiseResolveThenableJobInfo>::cast(microtask)->context();
- } else {
- context = Handle<PromiseReactionJobInfo>::cast(microtask)->context();
- }
+ do {
+ HandleScope handle_scope(this);
+ set_microtask_queue_bailout_index(-1);
+ set_microtask_queue_bailout_count(-1);
+ MaybeHandle<Object> maybe_exception;
+ MaybeHandle<Object> maybe_result = Execution::RunMicrotasks(
+ this, Execution::MessageHandling::kReport, &maybe_exception);
+ if (maybe_result.is_null() && maybe_exception.is_null()) {
+ heap()->set_microtask_queue(heap()->empty_fixed_array());
+ set_pending_microtask_count(0);
+ return;
+ }
- set_context(context->native_context());
- handle_scope_implementer_->EnterMicrotaskContext(
- Handle<Context>(context, this));
-
- MaybeHandle<Object> result;
- MaybeHandle<Object> maybe_exception;
-
- if (microtask->IsJSFunction()) {
- Handle<JSFunction> microtask_function =
- Handle<JSFunction>::cast(microtask);
- result = Execution::TryCall(
- this, microtask_function, factory()->undefined_value(), 0,
- nullptr, Execution::MessageHandling::kReport, &maybe_exception);
- } else if (microtask->IsPromiseResolveThenableJobInfo()) {
- PromiseResolveThenableJob(
- Handle<PromiseResolveThenableJobInfo>::cast(microtask), &result,
- &maybe_exception);
- } else {
- PromiseReactionJob(Handle<PromiseReactionJobInfo>::cast(microtask),
- &result, &maybe_exception);
- }
+ Handle<Object> result = maybe_result.ToHandleChecked();
+ if (result->IsUndefined(this)) return;
- handle_scope_implementer_->LeaveMicrotaskContext();
+ Handle<FixedArray> queue = Handle<FixedArray>::cast(result);
+ int num_tasks = microtask_queue_bailout_count();
+ DCHECK_GE(microtask_queue_bailout_index(), 0);
- // If execution is terminating, just bail out.
- if (result.is_null() && maybe_exception.is_null()) {
- // Clear out any remaining callbacks in the queue.
- heap()->set_microtask_queue(heap()->empty_fixed_array());
- set_pending_microtask_count(0);
- return;
- }
- }
- });
- }
+ Isolate* isolate = this;
+ FOR_WITH_HANDLE_SCOPE(
+ isolate, int, i = microtask_queue_bailout_index(), i, i < num_tasks,
+ i++, {
+ Handle<Object> microtask(queue->get(i), this);
+
+ if (microtask->IsCallHandlerInfo()) {
+ Handle<CallHandlerInfo> callback_info =
+ Handle<CallHandlerInfo>::cast(microtask);
+ v8::MicrotaskCallback callback =
+ v8::ToCData<v8::MicrotaskCallback>(callback_info->callback());
+ void* data = v8::ToCData<void*>(callback_info->data());
+ callback(data);
+ } else {
+ SaveContext save(this);
+ Context* context;
+ if (microtask->IsJSFunction()) {
+ context = Handle<JSFunction>::cast(microtask)->context();
+ } else if (microtask->IsPromiseResolveThenableJobInfo()) {
+ context = Handle<PromiseResolveThenableJobInfo>::cast(microtask)
+ ->context();
+ } else {
+ context =
+ Handle<PromiseReactionJobInfo>::cast(microtask)->context();
+ }
+
+ set_context(context->native_context());
+ handle_scope_implementer_->EnterMicrotaskContext(
+ Handle<Context>(context, this));
+
+ MaybeHandle<Object> result;
+ MaybeHandle<Object> maybe_exception;
+
+ if (microtask->IsJSFunction()) {
+ Handle<JSFunction> microtask_function =
+ Handle<JSFunction>::cast(microtask);
+ result = Execution::TryCall(
+ this, microtask_function, factory()->undefined_value(), 0,
+ nullptr, Execution::MessageHandling::kReport,
+ &maybe_exception);
+ } else if (microtask->IsPromiseResolveThenableJobInfo()) {
+ PromiseResolveThenableJob(
+ Handle<PromiseResolveThenableJobInfo>::cast(microtask),
+ &result, &maybe_exception);
+ } else {
+ PromiseReactionJob(
+ Handle<PromiseReactionJobInfo>::cast(microtask), &result,
+ &maybe_exception);
+ }
+
+ handle_scope_implementer_->LeaveMicrotaskContext();
+
+ // If execution is terminating, just bail out.
+ if (result.is_null() && maybe_exception.is_null()) {
+ // Clear out any remaining callbacks in the queue.
+ heap()->set_microtask_queue(heap()->empty_fixed_array());
+ set_pending_microtask_count(0);
+ return;
+ }
+ }
+ });
+ } while (pending_microtask_count() > 0);
}
void Isolate::SetUseCounterCallback(v8::Isolate::UseCounterCallback callback) {
@@ -3884,10 +4009,6 @@ void Isolate::PrintWithTimestamp(const char* format, ...) {
va_end(arguments);
}
-wasm::WasmCodeManager* Isolate::wasm_code_manager() {
- return wasm_code_manager_.get();
-}
-
bool StackLimitCheck::JsHasOverflowed(uintptr_t gap) const {
StackGuard* stack_guard = isolate_->stack_guard();
#ifdef USE_SIMULATOR