1// Copyright 2019 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "src/thread-local-top.h"
6#include "src/isolate.h"
7#include "src/simulator.h"
8#include "src/trap-handler/trap-handler.h"
9
10namespace v8 {
11namespace internal {
12
13void ThreadLocalTop::Initialize(Isolate* isolate) {
14 *this = ThreadLocalTop();
15 isolate_ = isolate;
16#ifdef USE_SIMULATOR
17 simulator_ = Simulator::current(isolate);
18#endif
19 thread_id_ = ThreadId::Current();
20 thread_in_wasm_flag_address_ = reinterpret_cast<Address>(
21 trap_handler::GetThreadInWasmThreadLocalAddress());
22}
23
24void ThreadLocalTop::Free() {
25 // Match unmatched PopPromise calls.
26 while (promise_on_stack_) isolate_->PopPromise();
27}
28
29} // namespace internal
30} // namespace v8
31