v8  3.11.10(node0.8.26)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
isolate.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_ISOLATE_H_
29 #define V8_ISOLATE_H_
30 
31 #include "../include/v8-debug.h"
32 #include "allocation.h"
33 #include "apiutils.h"
34 #include "atomicops.h"
35 #include "builtins.h"
36 #include "contexts.h"
37 #include "execution.h"
38 #include "frames.h"
39 #include "date.h"
40 #include "global-handles.h"
41 #include "handles.h"
42 #include "hashmap.h"
43 #include "heap.h"
44 #include "regexp-stack.h"
45 #include "runtime-profiler.h"
46 #include "runtime.h"
47 #include "zone.h"
48 
49 namespace v8 {
50 namespace internal {
51 
52 class Bootstrapper;
53 class CodeGenerator;
54 class CodeRange;
55 class CompilationCache;
56 class ContextSlotCache;
57 class ContextSwitcher;
58 class Counters;
59 class CpuFeatures;
60 class CpuProfiler;
61 class DeoptimizerData;
62 class Deserializer;
63 class EmptyStatement;
64 class ExternalReferenceTable;
65 class Factory;
66 class FunctionInfoListener;
67 class HandleScopeImplementer;
68 class HeapProfiler;
69 class InlineRuntimeFunctionsTable;
70 class NoAllocationStringAllocator;
71 class InnerPointerToCodeCache;
72 class PreallocatedMemoryThread;
73 class RegExpStack;
74 class SaveContext;
75 class UnicodeCache;
76 class StringInputBuffer;
77 class StringTracker;
78 class StubCache;
79 class ThreadManager;
80 class ThreadState;
81 class ThreadVisitor; // Defined in v8threads.h
82 class VMState;
83 
84 // 'void function pointer', used to roundtrip the
85 // ExternalReference::ExternalReferenceRedirector since we can not include
86 // assembler.h, where it is defined, here.
88 
89 
90 #ifdef ENABLE_DEBUGGER_SUPPORT
91 class Debug;
92 class Debugger;
93 class DebuggerAgent;
94 #endif
95 
96 #if !defined(__arm__) && defined(V8_TARGET_ARCH_ARM) || \
97  !defined(__mips__) && defined(V8_TARGET_ARCH_MIPS)
98 class Redirection;
99 class Simulator;
100 #endif
101 
102 
103 // Static indirection table for handles to constants. If a frame
104 // element represents a constant, the data contains an index into
105 // this table of handles to the actual constants.
106 // Static indirection table for handles to constants. If a Result
107 // represents a constant, the data contains an index into this table
108 // of handles to the actual constants.
110 
111 #define RETURN_IF_SCHEDULED_EXCEPTION(isolate) \
112  do { \
113  Isolate* __isolate__ = (isolate); \
114  if (__isolate__->has_scheduled_exception()) { \
115  return __isolate__->PromoteScheduledException(); \
116  } \
117  } while (false)
118 
119 #define RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, value) \
120  do { \
121  if ((call).is_null()) { \
122  ASSERT((isolate)->has_pending_exception()); \
123  return (value); \
124  } \
125  } while (false)
126 
127 #define CHECK_NOT_EMPTY_HANDLE(isolate, call) \
128  do { \
129  ASSERT(!(isolate)->has_pending_exception()); \
130  CHECK(!(call).is_null()); \
131  CHECK(!(isolate)->has_pending_exception()); \
132  } while (false)
133 
134 #define RETURN_IF_EMPTY_HANDLE(isolate, call) \
135  RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, Failure::Exception())
136 
137 #define FOR_EACH_ISOLATE_ADDRESS_NAME(C) \
138  C(Handler, handler) \
139  C(CEntryFP, c_entry_fp) \
140  C(Context, context) \
141  C(PendingException, pending_exception) \
142  C(ExternalCaughtException, external_caught_exception) \
143  C(JSEntrySP, js_entry_sp)
144 
145 
146 // Platform-independent, reliable thread identifier.
147 class ThreadId {
148  public:
149  // Creates an invalid ThreadId.
150  ThreadId() : id_(kInvalidId) {}
151 
152  // Returns ThreadId for current thread.
153  static ThreadId Current() { return ThreadId(GetCurrentThreadId()); }
154 
155  // Returns invalid ThreadId (guaranteed not to be equal to any thread).
156  static ThreadId Invalid() { return ThreadId(kInvalidId); }
157 
158  // Compares ThreadIds for equality.
159  INLINE(bool Equals(const ThreadId& other) const) {
160  return id_ == other.id_;
161  }
162 
163  // Checks whether this ThreadId refers to any thread.
164  INLINE(bool IsValid() const) {
165  return id_ != kInvalidId;
166  }
167 
168  // Converts ThreadId to an integer representation
169  // (required for public API: V8::V8::GetCurrentThreadId).
170  int ToInteger() const { return id_; }
171 
172  // Converts ThreadId to an integer representation
173  // (required for public API: V8::V8::TerminateExecution).
174  static ThreadId FromInteger(int id) { return ThreadId(id); }
175 
176  private:
177  static const int kInvalidId = -1;
178 
179  explicit ThreadId(int id) : id_(id) {}
180 
181  static int AllocateThreadId();
182 
183  static int GetCurrentThreadId();
184 
185  int id_;
186 
187  static Atomic32 highest_thread_id_;
188 
189  friend class Isolate;
190 };
191 
192 
193 class ThreadLocalTop BASE_EMBEDDED {
194  public:
195  // Does early low-level initialization that does not depend on the
196  // isolate being present.
197  ThreadLocalTop();
198 
199  // Initialize the thread data.
200  void Initialize();
201 
202  // Get the top C++ try catch handler or NULL if none are registered.
203  //
204  // This method is not guarenteed to return an address that can be
205  // used for comparison with addresses into the JS stack. If such an
206  // address is needed, use try_catch_handler_address.
207  v8::TryCatch* TryCatchHandler();
208 
209  // Get the address of the top C++ try catch handler or NULL if
210  // none are registered.
211  //
212  // This method always returns an address that can be compared to
213  // pointers into the JavaScript stack. When running on actual
214  // hardware, try_catch_handler_address and TryCatchHandler return
215  // the same pointer. When running on a simulator with a separate JS
216  // stack, try_catch_handler_address returns a JS stack address that
217  // corresponds to the place on the JS stack where the C++ handler
218  // would have been if the stack were not separate.
220  return try_catch_handler_address_;
221  }
222 
223  // Set the address of the top C++ try catch handler.
224  inline void set_try_catch_handler_address(Address address) {
225  try_catch_handler_address_ = address;
226  }
227 
228  void Free() {
229  ASSERT(!has_pending_message_);
230  ASSERT(!external_caught_exception_);
231  ASSERT(try_catch_handler_address_ == NULL);
232  }
233 
234  Isolate* isolate_;
235  // The context where the current execution method is created and for variable
236  // lookups.
239  MaybeObject* pending_exception_;
245  // Use a separate value for scheduled exceptions to preserve the
246  // invariants that hold about pending_exception. We may want to
247  // unify them later.
248  MaybeObject* scheduled_exception_;
250  SaveContext* save_context_;
252 
253  // Stack.
254  Address c_entry_fp_; // the frame pointer of the top c entry frame
255  Address handler_; // try-blocks are chained through the stack
256 
257 #ifdef USE_SIMULATOR
258 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS)
259  Simulator* simulator_;
260 #endif
261 #endif // USE_SIMULATOR
262 
263  Address js_entry_sp_; // the stack pointer of the bottom JS entry frame
264  Address external_callback_; // the external callback we're currently in
266 
267  // Generated code scratch locations.
269 
270  // Call back function to report unsafe JS accesses.
272 
273  // Head of the list of live LookupResults.
274  LookupResult* top_lookup_result_;
275 
276  // Whether out of memory exceptions should be ignored.
278 
279  private:
280  void InitializeInternal();
281 
282  Address try_catch_handler_address_;
283 };
284 
285 
286 #ifdef ENABLE_DEBUGGER_SUPPORT
287 
288 #define ISOLATE_DEBUGGER_INIT_LIST(V) \
289  V(v8::Debug::EventCallback, debug_event_callback, NULL) \
290  V(DebuggerAgent*, debugger_agent_instance, NULL)
291 #else
292 
293 #define ISOLATE_DEBUGGER_INIT_LIST(V)
294 
295 #endif
296 
297 #ifdef DEBUG
298 
299 #define ISOLATE_INIT_DEBUG_ARRAY_LIST(V) \
300  V(CommentStatistic, paged_space_comments_statistics, \
301  CommentStatistic::kMaxComments + 1)
302 #else
303 
304 #define ISOLATE_INIT_DEBUG_ARRAY_LIST(V)
305 
306 #endif
307 
308 #define ISOLATE_INIT_ARRAY_LIST(V) \
309  /* SerializerDeserializer state. */ \
310  V(Object*, serialize_partial_snapshot_cache, kPartialSnapshotCacheCapacity) \
311  V(int, jsregexp_static_offsets_vector, kJSRegexpStaticOffsetsVectorSize) \
312  V(int, bad_char_shift_table, kUC16AlphabetSize) \
313  V(int, good_suffix_shift_table, (kBMMaxShift + 1)) \
314  V(int, suffix_table, (kBMMaxShift + 1)) \
315  V(uint32_t, private_random_seed, 2) \
316  ISOLATE_INIT_DEBUG_ARRAY_LIST(V)
317 
319 
320 #define ISOLATE_INIT_LIST(V) \
321  /* SerializerDeserializer state. */ \
322  V(int, serialize_partial_snapshot_cache_length, 0) \
323  /* Assembler state. */ \
324  /* A previously allocated buffer of kMinimalBufferSize bytes, or NULL. */ \
325  V(byte*, assembler_spare_buffer, NULL) \
326  V(FatalErrorCallback, exception_behavior, NULL) \
327  V(AllowCodeGenerationFromStringsCallback, allow_code_gen_callback, NULL) \
328  V(v8::Debug::MessageHandler, message_handler, NULL) \
329  /* To distinguish the function templates, so that we can find them in the */ \
330  /* function cache of the global context. */ \
331  V(int, next_serial_number, 0) \
332  V(ExternalReferenceRedirectorPointer*, external_reference_redirector, NULL) \
333  V(bool, always_allow_natives_syntax, false) \
334  /* Part of the state of liveedit. */ \
335  V(FunctionInfoListener*, active_function_info_listener, NULL) \
336  /* State for Relocatable. */ \
337  V(Relocatable*, relocatable_top, NULL) \
338  /* State for CodeEntry in profile-generator. */ \
339  V(CodeGenerator*, current_code_generator, NULL) \
340  V(bool, jump_target_compiling_deferred_code, false) \
341  V(DebugObjectCache*, string_stream_debug_object_cache, NULL) \
342  V(Object*, string_stream_current_security_token, NULL) \
343  /* TODO(isolates): Release this on destruction? */ \
344  V(int*, irregexp_interpreter_backtrack_stack_cache, NULL) \
345  /* Serializer state. */ \
346  V(ExternalReferenceTable*, external_reference_table, NULL) \
347  /* AstNode state. */ \
348  V(int, ast_node_id, 0) \
349  V(unsigned, ast_node_count, 0) \
350  /* SafeStackFrameIterator activations count. */ \
351  V(int, safe_stack_iterator_counter, 0) \
352  V(uint64_t, enabled_cpu_features, 0) \
353  V(CpuProfiler*, cpu_profiler, NULL) \
354  V(HeapProfiler*, heap_profiler, NULL) \
355  ISOLATE_DEBUGGER_INIT_LIST(V)
356 
357 class Isolate {
358  // These forward declarations are required to make the friend declarations in
359  // PerIsolateThreadData work on some older versions of gcc.
360  class ThreadDataTable;
361  class EntryStackItem;
362  public:
363  ~Isolate();
364 
365  // A thread has a PerIsolateThreadData instance for each isolate that it has
366  // entered. That instance is allocated when the isolate is initially entered
367  // and reused on subsequent entries.
369  public:
371  : isolate_(isolate),
372  thread_id_(thread_id),
373  stack_limit_(0),
374  thread_state_(NULL),
375 #if !defined(__arm__) && defined(V8_TARGET_ARCH_ARM) || \
376  !defined(__mips__) && defined(V8_TARGET_ARCH_MIPS)
377  simulator_(NULL),
378 #endif
379  next_(NULL),
380  prev_(NULL) { }
381  Isolate* isolate() const { return isolate_; }
382  ThreadId thread_id() const { return thread_id_; }
383  void set_stack_limit(uintptr_t value) { stack_limit_ = value; }
384  uintptr_t stack_limit() const { return stack_limit_; }
385  ThreadState* thread_state() const { return thread_state_; }
386  void set_thread_state(ThreadState* value) { thread_state_ = value; }
387 
388 #if !defined(__arm__) && defined(V8_TARGET_ARCH_ARM) || \
389  !defined(__mips__) && defined(V8_TARGET_ARCH_MIPS)
390  Simulator* simulator() const { return simulator_; }
391  void set_simulator(Simulator* simulator) {
392  simulator_ = simulator;
393  }
394 #endif
395 
397  return isolate_ == isolate && thread_id_.Equals(thread_id);
398  }
399 
400  private:
401  Isolate* isolate_;
402  ThreadId thread_id_;
403  uintptr_t stack_limit_;
404  ThreadState* thread_state_;
405 
406 #if !defined(__arm__) && defined(V8_TARGET_ARCH_ARM) || \
407  !defined(__mips__) && defined(V8_TARGET_ARCH_MIPS)
408  Simulator* simulator_;
409 #endif
410 
411  PerIsolateThreadData* next_;
412  PerIsolateThreadData* prev_;
413 
414  friend class Isolate;
415  friend class ThreadDataTable;
416  friend class EntryStackItem;
417 
419  };
420 
421 
422  enum AddressId {
423 #define DECLARE_ENUM(CamelName, hacker_name) k##CamelName##Address,
425 #undef DECLARE_ENUM
427  };
428 
429  // Returns the PerIsolateThreadData for the current thread (or NULL if one is
430  // not currently set).
432  return reinterpret_cast<PerIsolateThreadData*>(
433  Thread::GetThreadLocal(per_isolate_thread_data_key_));
434  }
435 
436  // Returns the isolate inside which the current thread is running.
437  INLINE(static Isolate* Current()) {
438  Isolate* isolate = reinterpret_cast<Isolate*>(
439  Thread::GetExistingThreadLocal(isolate_key_));
440  ASSERT(isolate != NULL);
441  return isolate;
442  }
443 
444  INLINE(static Isolate* UncheckedCurrent()) {
445  return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key_));
446  }
447 
448  // Usually called by Init(), but can be called early e.g. to allow
449  // testing components that require logging but not the whole
450  // isolate.
451  //
452  // Safe to call more than once.
454 
455  bool Init(Deserializer* des);
456 
457  bool IsInitialized() { return state_ == INITIALIZED; }
458 
459  // True if at least one thread Enter'ed this isolate.
460  bool IsInUse() { return entry_stack_ != NULL; }
461 
462  // Destroys the non-default isolates.
463  // Sets default isolate into "has_been_disposed" state rather then destroying,
464  // for legacy API reasons.
465  void TearDown();
466 
467  bool IsDefaultIsolate() const { return this == default_isolate_; }
468 
469  // Ensures that process-wide resources and the default isolate have been
470  // allocated. It is only necessary to call this method in rare cases, for
471  // example if you are using V8 from within the body of a static initializer.
472  // Safe to call multiple times.
473  static void EnsureDefaultIsolate();
474 
475  // Find the PerThread for this particular (isolate, thread) combination
476  // If one does not yet exist, return null.
477  PerIsolateThreadData* FindPerThreadDataForThisThread();
478 
479 #ifdef ENABLE_DEBUGGER_SUPPORT
480  // Get the debugger from the default isolate. Preinitializes the
481  // default isolate if needed.
482  static Debugger* GetDefaultIsolateDebugger();
483 #endif
484 
485  // Get the stack guard from the default isolate. Preinitializes the
486  // default isolate if needed.
488 
489  // Returns the key used to store the pointer to the current isolate.
490  // Used internally for V8 threads that do not execute JavaScript but still
491  // are part of the domain of an isolate (like the context switcher).
493  return isolate_key_;
494  }
495 
496  // Returns the key used to store process-wide thread IDs.
498  return thread_id_key_;
499  }
500 
502 
503  // If a client attempts to create a Locker without specifying an isolate,
504  // we assume that the client is using legacy behavior. Set up the current
505  // thread to be inside the implicit isolate (or fail a check if we have
506  // switched to non-legacy behavior).
507  static void EnterDefaultIsolate();
508 
509  // Mutex for serializing access to break control structures.
510  Mutex* break_access() { return break_access_; }
511 
512  // Mutex for serializing access to debugger.
513  Mutex* debugger_access() { return debugger_access_; }
514 
516 
517  // Access to top context (where the current function object was created).
518  Context* context() { return thread_local_top_.context_; }
520  ASSERT(context == NULL || context->IsContext());
521  thread_local_top_.context_ = context;
522  }
523  Context** context_address() { return &thread_local_top_.context_; }
524 
525  SaveContext* save_context() {return thread_local_top_.save_context_; }
526  void set_save_context(SaveContext* save) {
527  thread_local_top_.save_context_ = save;
528  }
529 
530  // Access to current thread id.
531  ThreadId thread_id() { return thread_local_top_.thread_id_; }
532  void set_thread_id(ThreadId id) { thread_local_top_.thread_id_ = id; }
533 
534  // Interface to pending exception.
535  MaybeObject* pending_exception() {
537  return thread_local_top_.pending_exception_;
538  }
540  return thread_local_top_.external_caught_exception_;
541  }
542  void set_external_caught_exception(bool value) {
543  thread_local_top_.external_caught_exception_ = value;
544  }
545  void set_pending_exception(MaybeObject* exception) {
546  thread_local_top_.pending_exception_ = exception;
547  }
549  thread_local_top_.pending_exception_ = heap_.the_hole_value();
550  }
551  MaybeObject** pending_exception_address() {
552  return &thread_local_top_.pending_exception_;
553  }
555  return !thread_local_top_.pending_exception_->IsTheHole();
556  }
558  thread_local_top_.has_pending_message_ = false;
559  thread_local_top_.pending_message_obj_ = heap_.the_hole_value();
560  thread_local_top_.pending_message_script_ = NULL;
561  }
563  return thread_local_top_.TryCatchHandler();
564  }
566  return thread_local_top_.try_catch_handler_address();
567  }
569  return &thread_local_top_.external_caught_exception_;
570  }
572  return thread_local_top_.catcher_;
573  }
575  thread_local_top_.catcher_ = catcher;
576  }
577 
578  MaybeObject** scheduled_exception_address() {
579  return &thread_local_top_.scheduled_exception_;
580  }
581 
583  return reinterpret_cast<Address>(&thread_local_top_.pending_message_obj_);
584  }
585 
587  return reinterpret_cast<Address>(&thread_local_top_.has_pending_message_);
588  }
589 
591  return reinterpret_cast<Address>(
592  &thread_local_top_.pending_message_script_);
593  }
594 
595  MaybeObject* scheduled_exception() {
597  return thread_local_top_.scheduled_exception_;
598  }
600  return thread_local_top_.scheduled_exception_ != heap_.the_hole_value();
601  }
603  thread_local_top_.scheduled_exception_ = heap_.the_hole_value();
604  }
605 
606  bool IsExternallyCaught();
607 
608  bool is_catchable_by_javascript(MaybeObject* exception) {
609  return (exception != Failure::OutOfMemoryException()) &&
610  (exception != heap()->termination_exception());
611  }
612 
613  // JS execution stack (see frames.h).
614  static Address c_entry_fp(ThreadLocalTop* thread) {
615  return thread->c_entry_fp_;
616  }
617  static Address handler(ThreadLocalTop* thread) { return thread->handler_; }
618 
620  return &thread_local_top_.c_entry_fp_;
621  }
622  inline Address* handler_address() { return &thread_local_top_.handler_; }
623 
624  // Bottom JS entry (see StackTracer::Trace in log.cc).
625  static Address js_entry_sp(ThreadLocalTop* thread) {
626  return thread->js_entry_sp_;
627  }
629  return &thread_local_top_.js_entry_sp_;
630  }
631 
632  // Generated code scratch locations.
633  void* formal_count_address() { return &thread_local_top_.formal_count_; }
634 
635  // Returns the global object of the current context. It could be
636  // a builtin object, or a JS global object.
638  return Handle<GlobalObject>(context()->global());
639  }
640 
641  // Returns the global proxy object of the current context.
643  return context()->global_proxy();
644  }
645 
647  return Handle<JSBuiltinsObject>(thread_local_top_.context_->builtins());
648  }
649 
650  static int ArchiveSpacePerThread() { return sizeof(ThreadLocalTop); }
651  void FreeThreadResources() { thread_local_top_.Free(); }
652 
653  // This method is called by the api after operations that may throw
654  // exceptions. If an exception was thrown and not handled by an external
655  // handler the exception is scheduled to be rethrown when we return to running
656  // JavaScript code. If an exception is scheduled true is returned.
657  bool OptionalRescheduleException(bool is_bottom_call);
658 
660  public:
661  explicit ExceptionScope(Isolate* isolate) :
662  // Scope currently can only be used for regular exceptions, not
663  // failures like OOM or termination exception.
664  isolate_(isolate),
665  pending_exception_(isolate_->pending_exception()->ToObjectUnchecked()),
666  catcher_(isolate_->catcher())
667  { }
668 
670  isolate_->set_catcher(catcher_);
671  isolate_->set_pending_exception(*pending_exception_);
672  }
673 
674  private:
675  Isolate* isolate_;
676  Handle<Object> pending_exception_;
677  v8::TryCatch* catcher_;
678  };
679 
681  bool capture,
682  int frame_limit,
684 
685  // Tells whether the current context has experienced an out of memory
686  // exception.
687  bool is_out_of_memory();
689  return thread_local_top_.ignore_out_of_memory_;
690  }
691  void set_ignore_out_of_memory(bool value) {
692  thread_local_top_.ignore_out_of_memory_ = value;
693  }
694 
695  void PrintCurrentStackTrace(FILE* out);
696  void PrintStackTrace(FILE* out, char* thread_data);
697  void PrintStack(StringStream* accumulator);
698  void PrintStack();
701  int frame_limit,
703 
705 
706  // Returns if the top context may access the given global object. If
707  // the result is false, the pending exception is guaranteed to be
708  // set.
709  bool MayNamedAccess(JSObject* receiver,
710  Object* key,
712  bool MayIndexedAccess(JSObject* receiver,
713  uint32_t index,
715 
718 
719  // Exception throwing support. The caller should use the result
720  // of Throw() as its return value.
721  Failure* Throw(Object* exception, MessageLocation* location = NULL);
722  // Re-throw an exception. This involves no error reporting since
723  // error reporting was handled when the exception was thrown
724  // originally.
725  Failure* ReThrow(MaybeObject* exception);
726  void ScheduleThrow(Object* exception);
727  void ReportPendingMessages();
729 
730  // Promote a scheduled exception to pending. Asserts has_scheduled_exception.
732  void DoThrow(Object* exception, MessageLocation* location);
733  // Checks if exception should be reported and finds out if it's
734  // caught externally.
735  bool ShouldReportException(bool* can_be_caught_externally,
736  bool catchable_by_javascript);
737 
738  // Attempts to compute the current source location, storing the
739  // result in the target out parameter.
740  void ComputeLocation(MessageLocation* target);
741 
742  // Override command line flag.
743  void TraceException(bool flag);
744 
745  // Out of resource exception helpers.
748 
749  // Administration
750  void Iterate(ObjectVisitor* v);
751  void Iterate(ObjectVisitor* v, ThreadLocalTop* t);
752  char* Iterate(ObjectVisitor* v, char* t);
753  void IterateThread(ThreadVisitor* v);
754  void IterateThread(ThreadVisitor* v, char* t);
755 
756 
757  // Returns the current global context.
759 
760  // Returns the global context of the calling JavaScript code. That
761  // is, the global context of the top-most JavaScript frame.
763 
766 
767  char* ArchiveThread(char* to);
768  char* RestoreThread(char* from);
769 
770  static const char* const kStackOverflowMessage;
771 
772  static const int kUC16AlphabetSize = 256; // See StringSearchBase.
773  static const int kBMMaxShift = 250; // See StringSearchBase.
774 
775  // Accessors.
776 #define GLOBAL_ACCESSOR(type, name, initialvalue) \
777  inline type name() const { \
778  ASSERT(OFFSET_OF(Isolate, name##_) == name##_debug_offset_); \
779  return name##_; \
780  } \
781  inline void set_##name(type value) { \
782  ASSERT(OFFSET_OF(Isolate, name##_) == name##_debug_offset_); \
783  name##_ = value; \
784  }
786 #undef GLOBAL_ACCESSOR
787 
788 #define GLOBAL_ARRAY_ACCESSOR(type, name, length) \
789  inline type* name() { \
790  ASSERT(OFFSET_OF(Isolate, name##_) == name##_debug_offset_); \
791  return &(name##_)[0]; \
792  }
794 #undef GLOBAL_ARRAY_ACCESSOR
795 
796 #define GLOBAL_CONTEXT_FIELD_ACCESSOR(index, type, name) \
797  Handle<type> name() { \
798  return Handle<type>(context()->global_context()->name()); \
799  }
801 #undef GLOBAL_CONTEXT_FIELD_ACCESSOR
802 
803  Bootstrapper* bootstrapper() { return bootstrapper_; }
805  // Call InitializeLoggingAndCounters() if logging is needed before
806  // the isolate is fully initialized.
807  ASSERT(counters_ != NULL);
808  return counters_;
809  }
810  CodeRange* code_range() { return code_range_; }
811  RuntimeProfiler* runtime_profiler() { return runtime_profiler_; }
812  CompilationCache* compilation_cache() { return compilation_cache_; }
814  // Call InitializeLoggingAndCounters() if logging is needed before
815  // the isolate is fully initialized.
816  ASSERT(logger_ != NULL);
817  return logger_;
818  }
819  StackGuard* stack_guard() { return &stack_guard_; }
820  Heap* heap() { return &heap_; }
822  StubCache* stub_cache() { return stub_cache_; }
823  DeoptimizerData* deoptimizer_data() { return deoptimizer_data_; }
824  ThreadLocalTop* thread_local_top() { return &thread_local_top_; }
825 
827  return transcendental_cache_;
828  }
829 
831  return memory_allocator_;
832  }
833 
835  return keyed_lookup_cache_;
836  }
837 
839  return context_slot_cache_;
840  }
841 
843  return descriptor_lookup_cache_;
844  }
845 
847  return &handle_scope_data_;
848  }
850  ASSERT(handle_scope_implementer_);
851  return handle_scope_implementer_;
852  }
853  Zone* zone() { return &zone_; }
854 
856  return unicode_cache_;
857  }
858 
860  return inner_pointer_to_code_cache_;
861  }
862 
863  StringInputBuffer* write_input_buffer() { return write_input_buffer_; }
864 
865  GlobalHandles* global_handles() { return global_handles_; }
866 
867  ThreadManager* thread_manager() { return thread_manager_; }
868 
869  ContextSwitcher* context_switcher() { return context_switcher_; }
870 
872  context_switcher_ = switcher;
873  }
874 
875  StringTracker* string_tracker() { return string_tracker_; }
876 
878  return &jsregexp_uncanonicalize_;
879  }
880 
882  return &jsregexp_canonrange_;
883  }
884 
886  return &objects_string_compare_buffer_a_;
887  }
888 
890  return &objects_string_compare_buffer_b_;
891  }
892 
894  return &objects_string_input_buffer_;
895  }
896 
897  RuntimeState* runtime_state() { return &runtime_state_; }
898 
899  void set_fp_stubs_generated(bool value) {
900  fp_stubs_generated_ = value;
901  }
902 
903  bool fp_stubs_generated() { return fp_stubs_generated_; }
904 
906  return &compiler_safe_string_input_buffer_;
907  }
908 
909  Builtins* builtins() { return &builtins_; }
910 
912  has_installed_extensions_ = true;
913  }
914 
915  bool has_installed_extensions() { return has_installed_extensions_; }
916 
919  return &regexp_macro_assembler_canonicalize_;
920  }
921 
922  RegExpStack* regexp_stack() { return regexp_stack_; }
923 
926  return &interp_canonicalize_mapping_;
927  }
928 
929  void* PreallocatedStorageNew(size_t size);
930  void PreallocatedStorageDelete(void* p);
931  void PreallocatedStorageInit(size_t size);
932 
933 #ifdef ENABLE_DEBUGGER_SUPPORT
934  Debugger* debugger() {
935  if (!NoBarrier_Load(&debugger_initialized_)) InitializeDebugger();
936  return debugger_;
937  }
938  Debug* debug() {
939  if (!NoBarrier_Load(&debugger_initialized_)) InitializeDebugger();
940  return debug_;
941  }
942 #endif
943 
944  inline bool IsDebuggerActive();
945  inline bool DebuggerHasBreakPoints();
946 
947 #ifdef DEBUG
948  HistogramInfo* heap_histograms() { return heap_histograms_; }
949 
950  JSObject::SpillInformation* js_spill_information() {
951  return &js_spill_information_;
952  }
953 
954  int* code_kind_statistics() { return code_kind_statistics_; }
955 #endif
956 
957 #if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__) || \
958  defined(V8_TARGET_ARCH_MIPS) && !defined(__mips__)
959  bool simulator_initialized() { return simulator_initialized_; }
960  void set_simulator_initialized(bool initialized) {
961  simulator_initialized_ = initialized;
962  }
963 
964  HashMap* simulator_i_cache() { return simulator_i_cache_; }
965  void set_simulator_i_cache(HashMap* hash_map) {
966  simulator_i_cache_ = hash_map;
967  }
968 
969  Redirection* simulator_redirection() {
970  return simulator_redirection_;
971  }
972  void set_simulator_redirection(Redirection* redirection) {
973  simulator_redirection_ = redirection;
974  }
975 #endif
976 
977  Factory* factory() { return reinterpret_cast<Factory*>(this); }
978 
979  // SerializerDeserializer state.
980  static const int kPartialSnapshotCacheCapacity = 1400;
981 
982  static const int kJSRegexpStaticOffsetsVectorSize = 128;
983 
985  return thread_local_top_.external_callback_;
986  }
988  thread_local_top_.external_callback_ = callback;
989  }
990 
992  return thread_local_top_.current_vm_state_;
993  }
994 
997  // Make sure thread local top is initialized.
998  ASSERT(thread_local_top_.isolate_ == this);
999  StateTag current_state = thread_local_top_.current_vm_state_;
1000  if (current_state != JS && state == JS) {
1001  // Non-JS -> JS transition.
1003  } else if (current_state == JS && state != JS) {
1004  // JS -> non-JS transition.
1007  } else {
1008  // Other types of state transitions are not interesting to the
1009  // runtime profiler, because they don't affect whether we're
1010  // in JS or not.
1011  ASSERT((current_state == JS) == (state == JS));
1012  }
1013  }
1014  thread_local_top_.current_vm_state_ = state;
1015  }
1016 
1017  void SetData(void* data) { embedder_data_ = data; }
1018  void* GetData() { return embedder_data_; }
1019 
1020  LookupResult* top_lookup_result() {
1021  return thread_local_top_.top_lookup_result_;
1022  }
1023  void SetTopLookupResult(LookupResult* top) {
1024  thread_local_top_.top_lookup_result_ = top;
1025  }
1026 
1028  return context_exit_happened_;
1029  }
1031  context_exit_happened_ = context_exit_happened;
1032  }
1033 
1035  return OS::TimeCurrentMillis() - time_millis_at_init_;
1036  }
1037 
1039  return date_cache_;
1040  }
1041 
1043  if (date_cache != date_cache_) {
1044  delete date_cache_;
1045  }
1046  date_cache_ = date_cache;
1047  }
1048 
1049  private:
1050  Isolate();
1051 
1052  friend struct GlobalState;
1053  friend struct InitializeGlobalState;
1054 
1055  enum State {
1056  UNINITIALIZED, // Some components may not have been allocated.
1057  INITIALIZED // All components are fully initialized.
1058  };
1059 
1060  // These fields are accessed through the API, offsets must be kept in sync
1061  // with v8::internal::Internals (in include/v8.h) constants. This is also
1062  // verified in Isolate::Init() using runtime checks.
1063  State state_; // Will be padded to kApiPointerSize.
1064  void* embedder_data_;
1065  Heap heap_;
1066 
1067  // The per-process lock should be acquired before the ThreadDataTable is
1068  // modified.
1069  class ThreadDataTable {
1070  public:
1071  ThreadDataTable();
1072  ~ThreadDataTable();
1073 
1074  PerIsolateThreadData* Lookup(Isolate* isolate, ThreadId thread_id);
1075  void Insert(PerIsolateThreadData* data);
1076  void Remove(Isolate* isolate, ThreadId thread_id);
1077  void Remove(PerIsolateThreadData* data);
1078  void RemoveAllThreads(Isolate* isolate);
1079 
1080  private:
1081  PerIsolateThreadData* list_;
1082  };
1083 
1084  // These items form a stack synchronously with threads Enter'ing and Exit'ing
1085  // the Isolate. The top of the stack points to a thread which is currently
1086  // running the Isolate. When the stack is empty, the Isolate is considered
1087  // not entered by any thread and can be Disposed.
1088  // If the same thread enters the Isolate more then once, the entry_count_
1089  // is incremented rather then a new item pushed to the stack.
1090  class EntryStackItem {
1091  public:
1092  EntryStackItem(PerIsolateThreadData* previous_thread_data,
1093  Isolate* previous_isolate,
1094  EntryStackItem* previous_item)
1095  : entry_count(1),
1096  previous_thread_data(previous_thread_data),
1097  previous_isolate(previous_isolate),
1098  previous_item(previous_item) { }
1099 
1100  int entry_count;
1101  PerIsolateThreadData* previous_thread_data;
1102  Isolate* previous_isolate;
1103  EntryStackItem* previous_item;
1104 
1105  private:
1106  DISALLOW_COPY_AND_ASSIGN(EntryStackItem);
1107  };
1108 
1109  // This mutex protects highest_thread_id_, thread_data_table_ and
1110  // default_isolate_.
1111  static Mutex* process_wide_mutex_;
1112 
1113  static Thread::LocalStorageKey per_isolate_thread_data_key_;
1114  static Thread::LocalStorageKey isolate_key_;
1115  static Thread::LocalStorageKey thread_id_key_;
1116  static Isolate* default_isolate_;
1117  static ThreadDataTable* thread_data_table_;
1118 
1119  void Deinit();
1120 
1121  static void SetIsolateThreadLocals(Isolate* isolate,
1122  PerIsolateThreadData* data);
1123 
1124  // Allocate and insert PerIsolateThreadData into the ThreadDataTable
1125  // (regardless of whether such data already exists).
1126  PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id);
1127 
1128  // Find the PerThread for this particular (isolate, thread) combination.
1129  // If one does not yet exist, allocate a new one.
1130  PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread();
1131 
1132  // PreInits and returns a default isolate. Needed when a new thread tries
1133  // to create a Locker for the first time (the lock itself is in the isolate).
1134  static Isolate* GetDefaultIsolateForLocking();
1135 
1136  // Initializes the current thread to run this Isolate.
1137  // Not thread-safe. Multiple threads should not Enter/Exit the same isolate
1138  // at the same time, this should be prevented using external locking.
1139  void Enter();
1140 
1141  // Exits the current thread. The previosuly entered Isolate is restored
1142  // for the thread.
1143  // Not thread-safe. Multiple threads should not Enter/Exit the same isolate
1144  // at the same time, this should be prevented using external locking.
1145  void Exit();
1146 
1147  void PreallocatedMemoryThreadStart();
1148  void PreallocatedMemoryThreadStop();
1149  void InitializeThreadLocal();
1150 
1151  void PrintStackTrace(FILE* out, ThreadLocalTop* thread);
1152  void MarkCompactPrologue(bool is_compacting,
1153  ThreadLocalTop* archived_thread_data);
1154  void MarkCompactEpilogue(bool is_compacting,
1155  ThreadLocalTop* archived_thread_data);
1156 
1157  void FillCache();
1158 
1159  void PropagatePendingExceptionToExternalTryCatch();
1160 
1161  void InitializeDebugger();
1162 
1163  // Traverse prototype chain to find out whether the object is derived from
1164  // the Error object.
1165  bool IsErrorObject(Handle<Object> obj);
1166 
1167  EntryStackItem* entry_stack_;
1168  int stack_trace_nesting_level_;
1169  StringStream* incomplete_message_;
1170  // The preallocated memory thread singleton.
1171  PreallocatedMemoryThread* preallocated_memory_thread_;
1172  Address isolate_addresses_[kIsolateAddressCount + 1]; // NOLINT
1173  NoAllocationStringAllocator* preallocated_message_space_;
1174  Bootstrapper* bootstrapper_;
1175  RuntimeProfiler* runtime_profiler_;
1176  CompilationCache* compilation_cache_;
1177  Counters* counters_;
1178  CodeRange* code_range_;
1179  Mutex* break_access_;
1180  Atomic32 debugger_initialized_;
1181  Mutex* debugger_access_;
1182  Logger* logger_;
1183  StackGuard stack_guard_;
1184  StatsTable* stats_table_;
1185  StubCache* stub_cache_;
1186  DeoptimizerData* deoptimizer_data_;
1187  ThreadLocalTop thread_local_top_;
1188  bool capture_stack_trace_for_uncaught_exceptions_;
1189  int stack_trace_for_uncaught_exceptions_frame_limit_;
1190  StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options_;
1191  TranscendentalCache* transcendental_cache_;
1192  MemoryAllocator* memory_allocator_;
1193  KeyedLookupCache* keyed_lookup_cache_;
1194  ContextSlotCache* context_slot_cache_;
1195  DescriptorLookupCache* descriptor_lookup_cache_;
1197  HandleScopeImplementer* handle_scope_implementer_;
1198  UnicodeCache* unicode_cache_;
1199  Zone zone_;
1200  PreallocatedStorage in_use_list_;
1201  PreallocatedStorage free_list_;
1202  bool preallocated_storage_preallocated_;
1203  InnerPointerToCodeCache* inner_pointer_to_code_cache_;
1204  StringInputBuffer* write_input_buffer_;
1205  GlobalHandles* global_handles_;
1206  ContextSwitcher* context_switcher_;
1207  ThreadManager* thread_manager_;
1208  RuntimeState runtime_state_;
1209  bool fp_stubs_generated_;
1210  StaticResource<SafeStringInputBuffer> compiler_safe_string_input_buffer_;
1211  Builtins builtins_;
1212  bool has_installed_extensions_;
1213  StringTracker* string_tracker_;
1214  unibrow::Mapping<unibrow::Ecma262UnCanonicalize> jsregexp_uncanonicalize_;
1216  StringInputBuffer objects_string_compare_buffer_a_;
1217  StringInputBuffer objects_string_compare_buffer_b_;
1218  StaticResource<StringInputBuffer> objects_string_input_buffer_;
1220  regexp_macro_assembler_canonicalize_;
1221  RegExpStack* regexp_stack_;
1222  DateCache* date_cache_;
1223  unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_;
1224 
1225  // The garbage collector should be a little more aggressive when it knows
1226  // that a context was recently exited.
1227  bool context_exit_happened_;
1228 
1229  // Time stamp at initialization.
1230  double time_millis_at_init_;
1231 
1232 #if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__) || \
1233  defined(V8_TARGET_ARCH_MIPS) && !defined(__mips__)
1234  bool simulator_initialized_;
1235  HashMap* simulator_i_cache_;
1236  Redirection* simulator_redirection_;
1237 #endif
1238 
1239 #ifdef DEBUG
1240  // A static array of histogram info for each type.
1241  HistogramInfo heap_histograms_[LAST_TYPE + 1];
1242  JSObject::SpillInformation js_spill_information_;
1243  int code_kind_statistics_[Code::NUMBER_OF_KINDS];
1244 #endif
1245 
1246 #ifdef ENABLE_DEBUGGER_SUPPORT
1247  Debugger* debugger_;
1248  Debug* debug_;
1249 #endif
1250 
1251 #define GLOBAL_BACKING_STORE(type, name, initialvalue) \
1252  type name##_;
1254 #undef GLOBAL_BACKING_STORE
1255 
1256 #define GLOBAL_ARRAY_BACKING_STORE(type, name, length) \
1257  type name##_[length];
1259 #undef GLOBAL_ARRAY_BACKING_STORE
1260 
1261 #ifdef DEBUG
1262  // This class is huge and has a number of fields controlled by
1263  // preprocessor defines. Make sure the offsets of these fields agree
1264  // between compilation units.
1265 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
1266  static const intptr_t name##_debug_offset_;
1267  ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
1268  ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
1269 #undef ISOLATE_FIELD_OFFSET
1270 #endif
1271 
1272  friend class ExecutionAccess;
1273  friend class IsolateInitializer;
1274  friend class ThreadManager;
1275  friend class Simulator;
1276  friend class StackGuard;
1277  friend class ThreadId;
1279  friend class v8::Isolate;
1280  friend class v8::Locker;
1281  friend class v8::Unlocker;
1282 
1284 };
1285 
1286 
1287 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the
1288 // class as a work around for a bug in the generated code found with these
1289 // versions of GCC. See V8 issue 122 for details.
1290 class SaveContext BASE_EMBEDDED {
1291  public:
1292  inline explicit SaveContext(Isolate* isolate);
1293 
1295  if (context_.is_null()) {
1296  Isolate* isolate = Isolate::Current();
1297  isolate->set_context(NULL);
1298  isolate->set_save_context(prev_);
1299  } else {
1300  Isolate* isolate = context_->GetIsolate();
1301  isolate->set_context(*context_);
1302  isolate->set_save_context(prev_);
1303  }
1304  }
1305 
1306  Handle<Context> context() { return context_; }
1307  SaveContext* prev() { return prev_; }
1308 
1309  // Returns true if this save context is below a given JavaScript frame.
1311  return (c_entry_fp_ == 0) || (c_entry_fp_ > frame->sp());
1312  }
1313 
1314  private:
1315  Handle<Context> context_;
1316 #if __GNUC_VERSION__ >= 40100 && __GNUC_VERSION__ < 40300
1317  Handle<Context> dummy_;
1318 #endif
1319  SaveContext* prev_;
1320  Address c_entry_fp_;
1321 };
1322 
1323 
1324 class AssertNoContextChange BASE_EMBEDDED {
1325 #ifdef DEBUG
1326  public:
1327  AssertNoContextChange() :
1328  scope_(Isolate::Current()),
1329  context_(Isolate::Current()->context(), Isolate::Current()) {
1330  }
1331 
1332  ~AssertNoContextChange() {
1333  ASSERT(Isolate::Current()->context() == *context_);
1334  }
1335 
1336  private:
1337  HandleScope scope_;
1338  Handle<Context> context_;
1339 #else
1340  public:
1342 #endif
1343 };
1344 
1345 
1346 class ExecutionAccess BASE_EMBEDDED {
1347  public:
1348  explicit ExecutionAccess(Isolate* isolate) : isolate_(isolate) {
1349  Lock(isolate);
1350  }
1351  ~ExecutionAccess() { Unlock(isolate_); }
1352 
1353  static void Lock(Isolate* isolate) { isolate->break_access_->Lock(); }
1354  static void Unlock(Isolate* isolate) { isolate->break_access_->Unlock(); }
1355 
1356  static bool TryLock(Isolate* isolate) {
1357  return isolate->break_access_->TryLock();
1358  }
1359 
1360  private:
1361  Isolate* isolate_;
1362 };
1363 
1364 
1365 // Support for checking for stack-overflows in C++ code.
1366 class StackLimitCheck BASE_EMBEDDED {
1367  public:
1368  explicit StackLimitCheck(Isolate* isolate) : isolate_(isolate) { }
1369 
1370  bool HasOverflowed() const {
1371  StackGuard* stack_guard = isolate_->stack_guard();
1372  // Stack has overflowed in C++ code only if stack pointer exceeds the C++
1373  // stack guard and the limits are not set to interrupt values.
1374  // TODO(214): Stack overflows are ignored if a interrupt is pending. This
1375  // code should probably always use the initial C++ limit.
1376  return (reinterpret_cast<uintptr_t>(this) < stack_guard->climit()) &&
1377  stack_guard->IsStackOverflow();
1378  }
1379  private:
1380  Isolate* isolate_;
1381 };
1382 
1383 
1384 // Support for temporarily postponing interrupts. When the outermost
1385 // postpone scope is left the interrupts will be re-enabled and any
1386 // interrupts that occurred while in the scope will be taken into
1387 // account.
1388 class PostponeInterruptsScope BASE_EMBEDDED {
1389  public:
1391  : stack_guard_(isolate->stack_guard()) {
1392  stack_guard_->thread_local_.postpone_interrupts_nesting_++;
1393  stack_guard_->DisableInterrupts();
1394  }
1395 
1397  if (--stack_guard_->thread_local_.postpone_interrupts_nesting_ == 0) {
1398  stack_guard_->EnableInterrupts();
1399  }
1400  }
1401  private:
1402  StackGuard* stack_guard_;
1403 };
1404 
1405 
1406 // Temporary macros for accessing current isolate and its subobjects.
1407 // They provide better readability, especially when used a lot in the code.
1408 #define HEAP (v8::internal::Isolate::Current()->heap())
1409 #define FACTORY (v8::internal::Isolate::Current()->factory())
1410 #define ISOLATE (v8::internal::Isolate::Current())
1411 #define LOGGER (v8::internal::Isolate::Current()->logger())
1412 
1413 
1414 // Tells whether the global context is marked with out of memory.
1416  return global_context()->out_of_memory()->IsTrue();
1417 }
1418 
1419 
1420 // Mark the global context with out of memory.
1422  global_context()->set_out_of_memory(HEAP->true_value());
1423 }
1424 
1425 
1426 } } // namespace v8::internal
1427 
1428 #endif // V8_ISOLATE_H_
void PrintStackTrace(FILE *out, char *thread_data)
byte * Address
Definition: globals.h:172
static void Unlock(Isolate *isolate)
Definition: isolate.h:1354
ContextSlotCache * context_slot_cache()
Definition: isolate.h:838
void TraceException(bool flag)
Definition: isolate.cc:1240
friend struct GlobalState
Definition: isolate.h:1052
StackLimitCheck(Isolate *isolate)
Definition: isolate.h:1368
RuntimeState * runtime_state()
Definition: isolate.h:897
Failure * StackOverflow()
Definition: isolate.cc:897
static void * GetThreadLocal(LocalStorageKey key)
TranscendentalCache * transcendental_cache() const
Definition: isolate.h:826
void set_thread_id(ThreadId id)
Definition: isolate.h:532
bool has_out_of_memory()
Definition: isolate.h:1415
void set_date_cache(DateCache *date_cache)
Definition: isolate.h:1042
DateCache * date_cache()
Definition: isolate.h:1038
CodeRange * code_range()
Definition: isolate.h:810
virtual bool TryLock()=0
StaticResource< SafeStringInputBuffer > * compiler_safe_string_input_buffer()
Definition: isolate.h:905
MaybeObject * pending_exception()
Definition: isolate.h:535
CompilationCache * compilation_cache()
Definition: isolate.h:812
static Thread::LocalStorageKey per_isolate_thread_data_key()
#define DECLARE_ENUM(CamelName, hacker_name)
Definition: isolate.h:423
static void IsolateEnteredJS(Isolate *isolate)
void ScheduleThrow(Object *exception)
Definition: isolate.cc:944
GlobalObject * global()
Definition: contexts.h:319
#define GLOBAL_ARRAY_ACCESSOR(type, name, length)
Definition: isolate.h:788
unibrow::Mapping< unibrow::Ecma262UnCanonicalize > * jsregexp_uncanonicalize()
Definition: isolate.h:877
HandleScopeImplementer * handle_scope_implementer()
Definition: isolate.h:849
Address * js_entry_sp_address()
Definition: isolate.h:628
StateTag current_vm_state()
Definition: isolate.h:991
StringInputBuffer * objects_string_compare_buffer_a()
Definition: isolate.h:885
void ReportFailedAccessCheck(JSObject *receiver, v8::AccessType type)
Definition: isolate.cc:747
StackTraceOptions
Definition: v8.h:763
Mutex * break_access()
Definition: isolate.h:510
StatsTable * stats_table()
Definition: isolate.cc:1885
ExceptionScope(Isolate *isolate)
Definition: isolate.h:661
static Address js_entry_sp(ThreadLocalTop *thread)
Definition: isolate.h:625
static const int kJSRegexpStaticOffsetsVectorSize
Definition: isolate.h:982
bool MayNamedAccess(JSObject *receiver, Object *key, v8::AccessType type)
Definition: isolate.cc:801
ThreadId thread_id()
Definition: isolate.h:531
MaybeObject ** pending_exception_address()
Definition: isolate.h:551
Address get_address_from_id(AddressId id)
Definition: isolate.cc:417
static Failure * OutOfMemoryException()
Definition: objects-inl.h:1021
#define GLOBAL_BACKING_STORE(type, name, initialvalue)
Definition: isolate.h:1251
int ToInteger() const
Definition: isolate.h:170
#define GLOBAL_ARRAY_BACKING_STORE(type, name, length)
Definition: isolate.h:1256
MaybeObject * scheduled_exception_
Definition: isolate.h:248
void DoThrow(Object *exception, MessageLocation *location)
Definition: isolate.cc:1057
bool Init(Deserializer *des)
Definition: isolate.cc:1741
Handle< Context > context()
Definition: isolate.h:1306
Builtins * builtins()
Definition: isolate.h:909
int int32_t
Definition: unicode.cc:47
Address try_catch_handler_address()
Definition: isolate.h:219
void mark_out_of_memory()
Definition: isolate.h:1421
v8::HandleScope::Data HandleScopeData
Definition: apiutils.h:69
Bootstrapper * bootstrapper()
Definition: isolate.h:803
INLINE(static Isolate *Current())
Definition: isolate.h:437
Failure * ReThrow(MaybeObject *exception)
Definition: isolate.cc:924
PerIsolateThreadData * FindPerThreadDataForThisThread()
Definition: isolate.cc:352
static Address handler(ThreadLocalTop *thread)
Definition: isolate.h:617
Context * global_context()
Definition: contexts.cc:58
RegExpStack * regexp_stack()
Definition: isolate.h:922
virtual int Unlock()=0
#define ASSERT(condition)
Definition: checks.h:270
static PerIsolateThreadData * CurrentPerIsolateThreadData()
Definition: isolate.h:431
void SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback)
Definition: isolate.cc:741
static StackGuard * GetDefaultIsolateStackGuard()
Definition: isolate.cc:393
KeyedLookupCache * keyed_lookup_cache()
Definition: isolate.h:834
void clear_pending_exception()
Definition: isolate.h:548
void * formal_count_address()
Definition: isolate.h:633
ThreadManager * thread_manager()
Definition: isolate.h:867
void clear_scheduled_exception()
Definition: isolate.h:602
static Thread::LocalStorageKey isolate_key()
Definition: isolate.h:492
bool Matches(Isolate *isolate, ThreadId thread_id) const
Definition: isolate.h:396
INLINE(bool Equals(const ThreadId &other) const)
Definition: isolate.h:159
void PreallocatedStorageInit(size_t size)
Definition: isolate.cc:245
void * ExternalReferenceRedirectorPointer()
Definition: isolate.h:87
Factory * factory()
Definition: isolate.h:977
List< HeapObject *, PreallocatedStorageAllocationPolicy > DebugObjectCache
Definition: isolate.h:318
Context ** context_address()
Definition: isolate.h:523
bool external_caught_exception()
Definition: isolate.h:539
bool IsDefaultIsolate() const
Definition: isolate.h:467
PerIsolateThreadData(Isolate *isolate, ThreadId thread_id)
Definition: isolate.h:370
void(* FailedAccessCheckCallback)(Local< Object > target, AccessType type, Local< Value > data)
Definition: v8.h:2697
friend class StackGuard
Definition: isolate.h:1276
StringInputBuffer * objects_string_compare_buffer_b()
Definition: isolate.h:889
void clear_pending_message()
Definition: isolate.h:557
void CaptureAndSetCurrentStackTraceFor(Handle< JSObject > error_object)
Definition: isolate.cc:530
StackGuard * stack_guard()
Definition: isolate.h:819
void set_context_exit_happened(bool context_exit_happened)
Definition: isolate.h:1030
Handle< Context > global_context()
Definition: isolate.cc:1318
void set_external_callback(Address callback)
Definition: isolate.h:987
bool OptionalRescheduleException(bool is_bottom_call)
Definition: isolate.cc:1245
UnicodeCache * unicode_cache()
Definition: isolate.h:855
Address try_catch_handler_address()
Definition: isolate.h:565
void FreeThreadResources()
Definition: isolate.h:651
static void EnsureDefaultIsolate()
Definition: isolate.cc:363
#define GLOBAL_CONTEXT_FIELD_ACCESSOR(index, type, name)
Definition: isolate.h:796
Address * c_entry_fp_address()
Definition: isolate.h:619
void ReportPendingMessages()
Definition: isolate.cc:1203
#define ISOLATE_INIT_LIST(V)
Definition: isolate.h:320
INLINE(bool IsValid() const)
Definition: isolate.h:164
static Address c_entry_fp(ThreadLocalTop *thread)
Definition: isolate.h:614
friend class ThreadManager
Definition: isolate.h:1274
void set_catcher(v8::TryCatch *catcher)
Definition: isolate.h:574
Script * pending_message_script_
Definition: isolate.h:242
v8::TryCatch * try_catch_handler()
Definition: isolate.h:562
StringTracker * string_tracker()
Definition: isolate.h:875
RuntimeProfiler * runtime_profiler()
Definition: isolate.h:811
static ThreadId Current()
Definition: isolate.h:153
SaveContext * prev()
Definition: isolate.h:1307
bool context_exit_happened()
Definition: isolate.h:1027
void set_context(Context *context)
Definition: isolate.h:519
friend class IsolateInitializer
Definition: isolate.h:1273
void ComputeLocation(MessageLocation *target)
Definition: isolate.cc:990
void SetData(void *data)
Definition: isolate.h:1017
JSObject * global_proxy()
Definition: contexts.cc:78
static void EnterDefaultIsolate()
Definition: isolate.cc:399
unibrow::Mapping< unibrow::Ecma262Canonicalize > * regexp_macro_assembler_canonicalize()
Definition: isolate.h:918
MemoryAllocator * memory_allocator()
Definition: isolate.h:830
void NotifyExtensionInstalled()
Definition: isolate.h:911
MaybeObject * scheduled_exception()
Definition: isolate.h:595
Address has_pending_message_address()
Definition: isolate.h:586
void PrintCurrentStackTrace(FILE *out)
Definition: isolate.cc:962
void Iterate(ObjectVisitor *v)
Definition: isolate.cc:475
Handle< JSArray > CaptureCurrentStackTrace(int frame_limit, StackTrace::StackTraceOptions options)
Definition: isolate.cc:542
GlobalHandles * global_handles()
Definition: isolate.h:865
static void * GetExistingThreadLocal(LocalStorageKey key)
Definition: platform.h:487
SaveContext * save_context_
Definition: isolate.h:250
void SetCurrentVMState(StateTag state)
Definition: isolate.h:995
static void Lock(Isolate *isolate)
Definition: isolate.h:1353
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: globals.h:321
v8::ImplementationUtilities::HandleScopeData * handle_scope_data()
Definition: isolate.h:846
static double TimeCurrentMillis()
bool has_pending_exception()
Definition: isolate.h:554
PostponeInterruptsScope(Isolate *isolate)
Definition: isolate.h:1390
Address external_callback()
Definition: isolate.h:984
static const int kUC16AlphabetSize
Definition: isolate.h:772
AccessType
Definition: v8.h:2101
void * PreallocatedStorageNew(size_t size)
Definition: isolate.cc:257
void SetCaptureStackTraceForUncaughtExceptions(bool capture, int frame_limit, StackTrace::StackTraceOptions options)
Definition: isolate.cc:1291
Handle< JSBuiltinsObject > js_builtins_object()
Definition: isolate.h:646
Failure * Throw(Object *exception, MessageLocation *location=NULL)
Definition: isolate.cc:918
#define BASE_EMBEDDED
Definition: allocation.h:68
DeoptimizerData * deoptimizer_data()
Definition: isolate.h:823
friend class ThreadId
Definition: isolate.h:1277
DescriptorLookupCache * descriptor_lookup_cache()
Definition: isolate.h:842
void set_thread_state(ThreadState *value)
Definition: isolate.h:386
void SetTopLookupResult(LookupResult *top)
Definition: isolate.h:1023
StubCache * stub_cache()
Definition: isolate.h:822
v8::TryCatch * catcher_
Definition: isolate.h:251
bool has_installed_extensions()
Definition: isolate.h:915
Context * context()
Definition: isolate.h:518
Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr)
bool HasOverflowed() const
Definition: isolate.h:1370
Failure * PromoteScheduledException()
Definition: isolate.cc:954
InnerPointerToCodeCache * inner_pointer_to_code_cache()
Definition: isolate.h:859
v8::FailedAccessCheckCallback failed_access_check_callback_
Definition: isolate.h:271
static Thread::LocalStorageKey thread_id_key()
Definition: isolate.h:497
#define FOR_EACH_ISOLATE_ADDRESS_NAME(C)
Definition: isolate.h:137
void IterateThread(ThreadVisitor *v)
Definition: isolate.cc:429
static bool TryLock(Isolate *isolate)
Definition: isolate.h:1356
ThreadState * thread_state() const
Definition: isolate.h:385
static const int kPartialSnapshotCacheCapacity
Definition: isolate.h:980
StaticResource< StringInputBuffer > * objects_string_input_buffer()
Definition: isolate.h:893
static void IsolateExitedJS(Isolate *isolate)
Handle< String > StackTraceString()
Definition: isolate.cc:502
static ThreadId FromInteger(int id)
Definition: isolate.h:174
#define GLOBAL_ACCESSOR(type, name, initialvalue)
Definition: isolate.h:776
void set_pending_exception(MaybeObject *exception)
Definition: isolate.h:545
LookupResult * top_lookup_result_
Definition: isolate.h:274
bool DebuggerHasBreakPoints()
Definition: isolate-inl.h:62
void set_stack_limit(uintptr_t value)
Definition: isolate.h:383
Address pending_message_obj_address()
Definition: isolate.h:582
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kThisPropertyAssignmentsOffset flag
Definition: objects-inl.h:3682
TemplateHashMapImpl< FreeStoreAllocationPolicy > HashMap
Definition: hashmap.h:112
void set_try_catch_handler_address(Address address)
Definition: isolate.h:224
#define HEAP
Definition: isolate.h:1408
bool * external_caught_exception_address()
Definition: isolate.h:568
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
Definition: flags.cc:274
ZoneList< Handle< Object > > ZoneObjectList
Definition: ast.h:156
bool fp_stubs_generated()
Definition: isolate.h:903
static const int kBMMaxShift
Definition: isolate.h:773
static int ArchiveSpacePerThread()
Definition: isolate.h:650
bool MayIndexedAccess(JSObject *receiver, uint32_t index, v8::AccessType type)
Definition: isolate.cc:851
double time_millis_since_init()
Definition: isolate.h:1034
void set_ignore_out_of_memory(bool value)
Definition: isolate.h:691
Counters * counters()
Definition: isolate.h:804
void set_external_caught_exception(bool value)
Definition: isolate.h:542
void set_save_context(SaveContext *save)
Definition: isolate.h:526
Mutex * debugger_access()
Definition: isolate.h:513
MaybeObject ** scheduled_exception_address()
Definition: isolate.h:578
void InitializeLoggingAndCounters()
Definition: isolate.cc:1719
friend class Simulator
Definition: isolate.h:1275
ContextSwitcher * context_switcher()
Definition: isolate.h:869
void UnregisterTryCatchHandler(v8::TryCatch *that)
Definition: isolate.cc:493
Failure * TerminateExecution()
Definition: isolate.cc:912
char * ArchiveThread(char *to)
Definition: isolate.cc:1346
unibrow::Mapping< unibrow::CanonicalizationRange > * jsregexp_canonrange()
Definition: isolate.h:881
Failure * ThrowIllegalOperation()
Definition: isolate.cc:939
LookupResult * top_lookup_result()
Definition: isolate.h:1020
static ThreadId Invalid()
Definition: isolate.h:156
Logger * logger()
Definition: isolate.h:813
Handle< Context > GetCallingGlobalContext()
Definition: isolate.cc:1324
friend class ExecutionAccess
Definition: isolate.h:1272
Address pending_message_script_address()
Definition: isolate.h:590
void RegisterTryCatchHandler(v8::TryCatch *that)
Definition: isolate.cc:481
bool is_catchable_by_javascript(MaybeObject *exception)
Definition: isolate.h:608
int32_t Atomic32
Definition: atomicops.h:57
char * RestoreThread(char *from)
Definition: isolate.cc:1360
MaybeObject * pending_exception_
Definition: isolate.h:239
bool has_scheduled_exception()
Definition: isolate.h:599
void set_context_switcher(ContextSwitcher *switcher)
Definition: isolate.h:871
INLINE(static Isolate *UncheckedCurrent())
Definition: isolate.h:444
StringInputBuffer * write_input_buffer()
Definition: isolate.h:863
SaveContext * save_context()
Definition: isolate.h:525
Object * global_proxy()
Definition: isolate.h:642
unibrow::Mapping< unibrow::Ecma262Canonicalize > * interp_canonicalize_mapping()
Definition: isolate.h:925
bool IsBelowFrame(JavaScriptFrame *frame)
Definition: isolate.h:1310
bool ShouldReportException(bool *can_be_caught_externally, bool catchable_by_javascript)
Definition: isolate.cc:1008
virtual int Lock()=0
void set_fp_stubs_generated(bool value)
Definition: isolate.h:899
ThreadLocalTop * thread_local_top()
Definition: isolate.h:824
ExecutionAccess(Isolate *isolate)
Definition: isolate.h:1348
bool ignore_out_of_memory()
Definition: isolate.h:688
static const char *const kStackOverflowMessage
Definition: isolate.h:770
Handle< GlobalObject > global()
Definition: isolate.h:637
Address * handler_address()
Definition: isolate.h:622
FlagType type() const
Definition: flags.cc:1358
#define ISOLATE_INIT_ARRAY_LIST(V)
Definition: isolate.h:308
friend struct InitializeGlobalState
Definition: isolate.h:1053
void PreallocatedStorageDelete(void *p)
Definition: isolate.cc:300
#define GLOBAL_CONTEXT_FIELDS(V)
Definition: contexts.h:99
v8::TryCatch * catcher()
Definition: isolate.h:571