summaryrefslogtreecommitdiff
path: root/deps/v8/src/isolate.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/isolate.h')
-rw-r--r--deps/v8/src/isolate.h97
1 files changed, 60 insertions, 37 deletions
diff --git a/deps/v8/src/isolate.h b/deps/v8/src/isolate.h
index 9ef6fc732a..9ea30743bd 100644
--- a/deps/v8/src/isolate.h
+++ b/deps/v8/src/isolate.h
@@ -20,7 +20,7 @@
#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"
@@ -32,11 +32,12 @@ class RandomNumberGenerator;
namespace internal {
+class BasicBlockProfiler;
class Bootstrapper;
-class CallInterfaceDescriptor;
+class CallInterfaceDescriptorData;
class CodeGenerator;
class CodeRange;
-class CodeStubInterfaceDescriptor;
+class CodeStubDescriptor;
class CodeTracer;
class CompilationCache;
class ConsStringIteratorOp;
@@ -78,6 +79,7 @@ typedef void* ExternalReferenceRedirectorPointer();
class Debug;
class Debugger;
+class PromiseOnStack;
#if !defined(__arm__) && V8_TARGET_ARCH_ARM || \
!defined(__aarch64__) && V8_TARGET_ARCH_ARM64 || \
@@ -133,6 +135,22 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call, T) \
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, MaybeHandle<T>())
+#define THROW_NEW_ERROR(isolate, call, T) \
+ do { \
+ Handle<Object> __error__; \
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, __error__, isolate->factory()->call, \
+ T); \
+ return isolate->Throw<T>(__error__); \
+ } while (false)
+
+#define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call) \
+ do { \
+ Handle<Object> __error__; \
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, __error__, \
+ isolate->factory()->call); \
+ return isolate->Throw(*__error__); \
+ } while (false)
+
#define RETURN_ON_EXCEPTION_VALUE(isolate, call, value) \
do { \
if ((call).is_null()) { \
@@ -240,11 +258,7 @@ class ThreadLocalTop BASE_EMBEDDED {
v8::TryCatch::JSStackComparableAddress(try_catch_handler()));
}
- void Free() {
- DCHECK(!has_pending_message_);
- DCHECK(!external_caught_exception_);
- DCHECK(try_catch_handler_ == NULL);
- }
+ void Free();
Isolate* isolate_;
// The context where the current execution method is created and for variable
@@ -270,6 +284,11 @@ class ThreadLocalTop BASE_EMBEDDED {
Address c_entry_fp_; // the frame pointer of the top c entry frame
Address handler_; // try-blocks are chained through the stack
+ // Throwing an exception may cause a Promise rejection. For this purpose
+ // we keep track of a stack of nested promises and the corresponding
+ // try-catch handlers.
+ PromiseOnStack* promise_on_stack_;
+
#ifdef USE_SIMULATOR
Simulator* simulator_;
#endif
@@ -355,9 +374,6 @@ typedef List<HeapObject*> DebugObjectCache;
V(Object*, string_stream_current_security_token, NULL) \
/* Serializer state. */ \
V(ExternalReferenceTable*, external_reference_table, NULL) \
- /* AstNode state. */ \
- V(int, ast_node_id, 0) \
- V(unsigned, ast_node_count, 0) \
V(int, pending_microtask_count, 0) \
V(bool, autorun_microtasks, true) \
V(HStatistics*, hstatistics, NULL) \
@@ -451,17 +467,17 @@ class Isolate {
kIsolateAddressCount
};
+ static void InitializeOncePerProcess();
+
// Returns the PerIsolateThreadData for the current thread (or NULL if one is
// not currently set).
static PerIsolateThreadData* CurrentPerIsolateThreadData() {
- EnsureInitialized();
return reinterpret_cast<PerIsolateThreadData*>(
base::Thread::GetThreadLocal(per_isolate_thread_data_key_));
}
// Returns the isolate inside which the current thread is running.
INLINE(static Isolate* Current()) {
- EnsureInitialized();
Isolate* isolate = reinterpret_cast<Isolate*>(
base::Thread::GetExistingThreadLocal(isolate_key_));
DCHECK(isolate != NULL);
@@ -469,7 +485,6 @@ class Isolate {
}
INLINE(static Isolate* UncheckedCurrent()) {
- EnsureInitialized();
return reinterpret_cast<Isolate*>(
base::Thread::GetThreadLocal(isolate_key_));
}
@@ -514,13 +529,11 @@ class Isolate {
// Used internally for V8 threads that do not execute JavaScript but still
// are part of the domain of an isolate (like the context switcher).
static base::Thread::LocalStorageKey isolate_key() {
- EnsureInitialized();
return isolate_key_;
}
// Returns the key used to store process-wide thread IDs.
static base::Thread::LocalStorageKey thread_id_key() {
- EnsureInitialized();
return thread_id_key_;
}
@@ -676,6 +689,11 @@ class Isolate {
// JavaScript code. If an exception is scheduled true is returned.
bool OptionalRescheduleException(bool is_bottom_call);
+ // Push and pop a promise and the current try-catch handler.
+ void PushPromise(Handle<JSObject> promise);
+ void PopPromise();
+ Handle<Object> GetPromiseOnStackOnThrow();
+
class ExceptionScope {
public:
explicit ExceptionScope(Isolate* isolate) :
@@ -758,7 +776,6 @@ class Isolate {
// Return pending location if any or unfilled structure.
MessageLocation GetMessageLocation();
Object* ThrowIllegalOperation();
- Object* ThrowInvalidStringLength();
// Promote a scheduled exception to pending. Asserts has_scheduled_exception.
Object* PromoteScheduledException();
@@ -1015,19 +1032,7 @@ class Isolate {
bool IsFastArrayConstructorPrototypeChainIntact();
- CodeStubInterfaceDescriptor*
- code_stub_interface_descriptor(int index);
-
- enum CallDescriptorKey {
- KeyedCall,
- NamedCall,
- CallHandler,
- ArgumentAdaptorCall,
- ApiFunctionCall,
- NUMBER_OF_CALL_DESCRIPTORS
- };
-
- CallInterfaceDescriptor* call_descriptor(CallDescriptorKey index);
+ CallInterfaceDescriptorData* call_descriptor_data(int index);
void IterateDeferredHandles(ObjectVisitor* visitor);
void LinkDeferredHandles(DeferredHandles* deferred_handles);
@@ -1103,9 +1108,12 @@ class Isolate {
void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback);
void CountUsage(v8::Isolate::UseCounterFeature feature);
- private:
- static void EnsureInitialized();
+ BasicBlockProfiler* GetOrCreateBasicBlockProfiler();
+ BasicBlockProfiler* basic_block_profiler() { return basic_block_profiler_; }
+
+ static Isolate* NewForTesting() { return new Isolate(); }
+ private:
Isolate();
friend struct GlobalState;
@@ -1164,8 +1172,7 @@ class Isolate {
DISALLOW_COPY_AND_ASSIGN(EntryStackItem);
};
- // This mutex protects highest_thread_id_ and thread_data_table_.
- static base::LazyMutex process_wide_mutex_;
+ static base::LazyMutex thread_data_table_mutex_;
static base::Thread::LocalStorageKey per_isolate_thread_data_key_;
static base::Thread::LocalStorageKey isolate_key_;
@@ -1263,8 +1270,7 @@ class Isolate {
RegExpStack* regexp_stack_;
DateCache* date_cache_;
unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_;
- CodeStubInterfaceDescriptor* code_stub_interface_descriptors_;
- CallInterfaceDescriptor* call_descriptors_;
+ CallInterfaceDescriptorData* call_descriptor_data_;
base::RandomNumberGenerator* random_number_generator_;
// Whether the isolate has been created for snapshotting.
@@ -1325,6 +1331,7 @@ class Isolate {
List<CallCompletedCallback> call_completed_callbacks_;
v8::Isolate::UseCounterCallback use_counter_callback_;
+ BasicBlockProfiler* basic_block_profiler_;
friend class ExecutionAccess;
friend class HandleScopeImplementer;
@@ -1349,6 +1356,22 @@ class Isolate {
#undef THREAD_LOCAL_TOP_ACCESSOR
+class PromiseOnStack {
+ public:
+ PromiseOnStack(StackHandler* handler, Handle<JSObject> promise,
+ PromiseOnStack* prev)
+ : handler_(handler), promise_(promise), prev_(prev) {}
+ StackHandler* handler() { return handler_; }
+ Handle<JSObject> promise() { return promise_; }
+ PromiseOnStack* prev() { return prev_; }
+
+ private:
+ StackHandler* handler_;
+ Handle<JSObject> promise_;
+ PromiseOnStack* prev_;
+};
+
+
// If the GCC version is 4.1.x or 4.2.x an additional field is added to the
// class as a work around for a bug in the generated code found with these
// versions of GCC. See V8 issue 122 for details.
@@ -1467,7 +1490,7 @@ class PostponeInterruptsScope BASE_EMBEDDED {
};
-class CodeTracer V8_FINAL : public Malloced {
+class CodeTracer FINAL : public Malloced {
public:
explicit CodeTracer(int isolate_id)
: file_(NULL),