#include "src/heap/heap.h"
#include "src/optimizing-compiler-thread.h"
#include "src/regexp-stack.h"
-#include "src/runtime.h"
+#include "src/runtime/runtime.h"
#include "src/runtime-profiler.h"
#include "src/zone.h"
namespace internal {
+class BasicBlockProfiler;
class Bootstrapper;
class CallInterfaceDescriptorData;
class CodeGenerator;
class CodeStubDescriptor;
class CodeTracer;
class CompilationCache;
-class ConsStringIteratorOp;
+class CompilationStatistics;
class ContextSlotCache;
class Counters;
class CpuFeatures;
#define FOR_EACH_ISOLATE_ADDRESS_NAME(C) \
C(Handler, handler) \
C(CEntryFP, c_entry_fp) \
+ C(CFunction, c_function) \
C(Context, context) \
C(PendingException, pending_exception) \
C(ExternalCaughtException, external_caught_exception) \
class ThreadId {
public:
// Creates an invalid ThreadId.
- ThreadId() : id_(kInvalidId) {}
+ ThreadId() { base::NoBarrier_Store(&id_, kInvalidId); }
+
+ ThreadId& operator=(const ThreadId& other) {
+ base::NoBarrier_Store(&id_, base::NoBarrier_Load(&other.id_));
+ return *this;
+ }
// Returns ThreadId for current thread.
static ThreadId Current() { return ThreadId(GetCurrentThreadId()); }
// Compares ThreadIds for equality.
INLINE(bool Equals(const ThreadId& other) const) {
- return id_ == other.id_;
+ return base::NoBarrier_Load(&id_) == base::NoBarrier_Load(&other.id_);
}
// Checks whether this ThreadId refers to any thread.
INLINE(bool IsValid() const) {
- return id_ != kInvalidId;
+ return base::NoBarrier_Load(&id_) != kInvalidId;
}
// Converts ThreadId to an integer representation
// (required for public API: V8::V8::GetCurrentThreadId).
- int ToInteger() const { return id_; }
+ int ToInteger() const { return static_cast<int>(base::NoBarrier_Load(&id_)); }
// Converts ThreadId to an integer representation
// (required for public API: V8::V8::TerminateExecution).
private:
static const int kInvalidId = -1;
- explicit ThreadId(int id) : id_(id) {}
+ explicit ThreadId(int id) { base::NoBarrier_Store(&id_, id); }
static int AllocateThreadId();
static int GetCurrentThreadId();
- int id_;
+ base::Atomic32 id_;
static base::Atomic32 highest_thread_id_;
// Stack.
Address c_entry_fp_; // the frame pointer of the top c entry frame
Address handler_; // try-blocks are chained through the stack
+ Address c_function_; // C function that was called at c entry.
// Throwing an exception may cause a Promise rejection. For this purpose
// we keep track of a stack of nested promises and the corresponding
V(int, pending_microtask_count, 0) \
V(bool, autorun_microtasks, true) \
V(HStatistics*, hstatistics, NULL) \
- V(HStatistics*, tstatistics, NULL) \
+ V(CompilationStatistics*, turbo_statistics, NULL) \
V(HTracer*, htracer, NULL) \
V(CodeTracer*, code_tracer, NULL) \
V(bool, fp_stubs_generated, false) \
V(uint32_t, per_isolate_assert_data, 0xFFFFFFFFu) \
V(InterruptCallback, api_interrupt_callback, NULL) \
V(void*, api_interrupt_callback_data, NULL) \
+ V(PromiseRejectCallback, promise_reject_callback, NULL) \
ISOLATE_INIT_SIMULATOR_LIST(V)
#define THREAD_LOCAL_TOP_ACCESSOR(type, name) \
bool Init(Deserializer* des);
- bool IsInitialized() { return state_ == INITIALIZED; }
-
// True if at least one thread Enter'ed this isolate.
bool IsInUse() { return entry_stack_ != NULL; }
return thread->c_entry_fp_;
}
static Address handler(ThreadLocalTop* thread) { return thread->handler_; }
+ Address c_function() { return thread_local_top_.c_function_; }
inline Address* c_entry_fp_address() {
return &thread_local_top_.c_entry_fp_;
}
inline Address* handler_address() { return &thread_local_top_.handler_; }
+ inline Address* c_function_address() {
+ return &thread_local_top_.c_function_;
+ }
// Bottom JS entry.
Address js_entry_sp() {
void CaptureAndSetDetailedStackTrace(Handle<JSObject> error_object);
void CaptureAndSetSimpleStackTrace(Handle<JSObject> error_object,
Handle<Object> caller);
+ Handle<JSArray> GetDetailedStackTrace(Handle<JSObject> error_object);
+ Handle<JSArray> GetDetailedFromSimpleStackTrace(
+ Handle<JSObject> error_object);
// Returns if the top context may access the given global object. If
// the result is false, the pending exception is guaranteed to be
// Attempts to compute the current source location, storing the
// result in the target out parameter.
void ComputeLocation(MessageLocation* target);
+ bool ComputeLocationFromStackTrace(MessageLocation* target,
+ Handle<Object> exception);
+
+ Handle<JSMessageObject> CreateMessage(Handle<Object> exception,
+ MessageLocation* location);
// Out of resource exception helpers.
Object* StackOverflow();
return inner_pointer_to_code_cache_;
}
- ConsStringIteratorOp* write_iterator() { return write_iterator_; }
-
GlobalHandles* global_handles() { return global_handles_; }
EternalHandles* eternal_handles() { return eternal_handles_; }
return &jsregexp_canonrange_;
}
- ConsStringIteratorOp* objects_string_compare_iterator_a() {
- return &objects_string_compare_iterator_a_;
- }
-
- ConsStringIteratorOp* objects_string_compare_iterator_b() {
- return &objects_string_compare_iterator_b_;
- }
-
- StaticResource<ConsStringIteratorOp>* objects_string_iterator() {
- return &objects_string_iterator_;
- }
-
RuntimeState* runtime_state() { return &runtime_state_; }
Builtins* builtins() { return &builtins_; }
THREAD_LOCAL_TOP_ACCESSOR(LookupResult*, top_lookup_result)
- void enable_serializer() {
- // The serializer can only be enabled before the isolate init.
- DCHECK(state_ != INITIALIZED);
- serializer_enabled_ = true;
- }
-
bool serializer_enabled() const { return serializer_enabled_; }
bool IsDead() { return has_fatal_error_; }
return optimizing_compiler_thread_;
}
- int num_sweeper_threads() const {
- return num_sweeper_threads_;
- }
-
- SweeperThread** sweeper_threads() {
- return sweeper_thread_;
- }
-
int id() const { return static_cast<int>(id_); }
HStatistics* GetHStatistics();
- HStatistics* GetTStatistics();
+ CompilationStatistics* GetTurboStatistics();
HTracer* GetHTracer();
CodeTracer* GetCodeTracer();
void RemoveCallCompletedCallback(CallCompletedCallback callback);
void FireCallCompletedCallback();
+ void SetPromiseRejectCallback(PromiseRejectCallback callback);
+ void ReportPromiseReject(Handle<JSObject> promise, Handle<Object> value,
+ v8::PromiseRejectEvent event);
+
void EnqueueMicrotask(Handle<Object> microtask);
void RunMicrotasks();
void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback);
void CountUsage(v8::Isolate::UseCounterFeature feature);
- static Isolate* NewForTesting() { return new Isolate(); }
+ BasicBlockProfiler* GetOrCreateBasicBlockProfiler();
+ BasicBlockProfiler* basic_block_profiler() { return basic_block_profiler_; }
+
+ static Isolate* NewForTesting() { return new Isolate(false); }
+
+ std::string GetTurboCfgFileName();
private:
- Isolate();
+ explicit Isolate(bool enable_serializer);
friend struct GlobalState;
friend struct InitializeGlobalState;
- enum State {
- UNINITIALIZED, // Some components may not have been allocated.
- INITIALIZED // All components are fully initialized.
- };
-
// These fields are accessed through the API, offsets must be kept in sync
// with v8::internal::Internals (in include/v8.h) constants. This is also
// verified in Isolate::Init() using runtime checks.
void* embedder_data_[Internals::kNumIsolateDataSlots];
Heap heap_;
- State state_; // Will be padded to kApiPointerSize.
// The per-process lock should be acquired before the ThreadDataTable is
// modified.
UnicodeCache* unicode_cache_;
Zone runtime_zone_;
InnerPointerToCodeCache* inner_pointer_to_code_cache_;
- ConsStringIteratorOp* write_iterator_;
GlobalHandles* global_handles_;
EternalHandles* eternal_handles_;
ThreadManager* thread_manager_;
StringTracker* string_tracker_;
unibrow::Mapping<unibrow::Ecma262UnCanonicalize> jsregexp_uncanonicalize_;
unibrow::Mapping<unibrow::CanonicalizationRange> jsregexp_canonrange_;
- ConsStringIteratorOp objects_string_compare_iterator_a_;
- ConsStringIteratorOp objects_string_compare_iterator_b_;
- StaticResource<ConsStringIteratorOp> objects_string_iterator_;
unibrow::Mapping<unibrow::Ecma262Canonicalize>
regexp_macro_assembler_canonicalize_;
RegExpStack* regexp_stack_;
DeferredHandles* deferred_handles_head_;
OptimizingCompilerThread* optimizing_compiler_thread_;
- SweeperThread** sweeper_thread_;
- int num_sweeper_threads_;
// Counts deopt points if deopt_every_n_times is enabled.
unsigned int stress_deopt_count_;
List<CallCompletedCallback> call_completed_callbacks_;
v8::Isolate::UseCounterCallback use_counter_callback_;
+ BasicBlockProfiler* basic_block_profiler_;
friend class ExecutionAccess;
friend class HandleScopeImplementer;