1a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Copyright 2006-2008 the V8 project authors. All rights reserved.
2a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Redistribution and use in source and binary forms, with or without
3a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// modification, are permitted provided that the following conditions are
4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// met:
5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Redistributions of source code must retain the above copyright
7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       notice, this list of conditions and the following disclaimer.
8a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Redistributions in binary form must reproduce the above
9a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       copyright notice, this list of conditions and the following
10a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       disclaimer in the documentation and/or other materials provided
11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       with the distribution.
12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Neither the name of Google Inc. nor the names of its
13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       contributors may be used to endorse or promote products derived
14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       from this software without specific prior written permission.
15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifndef V8_TOP_H_
29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define V8_TOP_H_
30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "frames-inl.h"
32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace v8 {
34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace internal {
35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define RETURN_IF_SCHEDULED_EXCEPTION() \
38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  if (Top::has_scheduled_exception()) return Top::PromoteScheduledException()
39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
40a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Top has static variables used for JavaScript execution.
41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass SaveContext;  // Forward declaration.
43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass ThreadLocalTop BASE_EMBEDDED {
45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
46d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // Initialize the thread data.
47d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  void Initialize();
48d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block
49d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // Get the top C++ try catch handler or NULL if none are registered.
50d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  //
51d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // This method is not guarenteed to return an address that can be
52d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // used for comparison with addresses into the JS stack.  If such an
53d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // address is needed, use try_catch_handler_address.
54d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  v8::TryCatch* TryCatchHandler();
55d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block
56d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // Get the address of the top C++ try catch handler or NULL if
57d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // none are registered.
58d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  //
59d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // This method always returns an address that can be compared to
60d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // pointers into the JavaScript stack.  When running on actual
61d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // hardware, try_catch_handler_address and TryCatchHandler return
62d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // the same pointer.  When running on a simulator with a separate JS
63d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // stack, try_catch_handler_address returns a JS stack address that
64d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // corresponds to the place on the JS stack where the C++ handler
65d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // would have been if the stack were not separate.
66d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  inline Address try_catch_handler_address() {
67d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block    return try_catch_handler_address_;
68d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  }
69d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block
70d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // Set the address of the top C++ try catch handler.
71d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  inline void set_try_catch_handler_address(Address address) {
72d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block    try_catch_handler_address_ = address;
73d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  }
74d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block
75d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  void Free() {
76d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block    ASSERT(!has_pending_message_);
77d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block    ASSERT(!external_caught_exception_);
78d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block    ASSERT(try_catch_handler_address_ == NULL);
79d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  }
80d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block
81a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // The context where the current execution method is created and for variable
82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // lookups.
83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Context* context_;
84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  int thread_id_;
85a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Object* pending_exception_;
86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  bool has_pending_message_;
87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  const char* pending_message_;
88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Object* pending_message_obj_;
89a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Script* pending_message_script_;
90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  int pending_message_start_pos_;
91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  int pending_message_end_pos_;
92a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Use a separate value for scheduled exceptions to preserve the
93a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // invariants that hold about pending_exception.  We may want to
94a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // unify them later.
95a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Object* scheduled_exception_;
96a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  bool external_caught_exception_;
97a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  SaveContext* save_context_;
98a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  v8::TryCatch* catcher_;
99a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
100a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Stack.
101a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Address c_entry_fp_;  // the frame pointer of the top c entry frame
102a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Address handler_;   // try-blocks are chained through the stack
103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifdef ENABLE_LOGGING_AND_PROFILING
104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Address js_entry_sp_;  // the stack pointer of the bottom js entry frame
105a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif
106a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  bool stack_is_cooked_;
107a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline bool stack_is_cooked() { return stack_is_cooked_; }
108a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void set_stack_is_cooked(bool value) { stack_is_cooked_ = value; }
109a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
110a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Generated code scratch locations.
111a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  int32_t formal_count_;
112a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
113a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Call back function to report unsafe JS accesses.
114a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  v8::FailedAccessCheckCallback failed_access_check_callback_;
115a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
116d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block private:
117d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  Address try_catch_handler_address_;
118a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
119a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
120d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block#define TOP_ADDRESS_LIST(C)            \
121a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  C(handler_address)                   \
122a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  C(c_entry_fp_address)                \
123a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  C(context_address)                   \
124a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  C(pending_exception_address)         \
125a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  C(external_caught_exception_address)
126a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
127a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifdef ENABLE_LOGGING_AND_PROFILING
128a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define TOP_ADDRESS_LIST_PROF(C)       \
129a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  C(js_entry_sp_address)
130a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#else
131a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define TOP_ADDRESS_LIST_PROF(C)
132a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif
133a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
134a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
135a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass Top {
136a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
137a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  enum AddressId {
138a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define C(name) k_##name,
139a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    TOP_ADDRESS_LIST(C)
140a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    TOP_ADDRESS_LIST_PROF(C)
141a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#undef C
142a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    k_top_address_count
143a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  };
144a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
145a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Address get_address_from_id(AddressId id);
146a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
147a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Access to top context (where the current function object was created).
148a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Context* context() { return thread_local_.context_; }
149a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void set_context(Context* context) {
150a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    thread_local_.context_ = context;
151a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
152a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Context** context_address() { return &thread_local_.context_; }
153a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
154a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static SaveContext* save_context() {return thread_local_.save_context_; }
155a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void set_save_context(SaveContext* save) {
156a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    thread_local_.save_context_ = save;
157a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
158a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
159a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Access to current thread id.
160a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static int thread_id() { return thread_local_.thread_id_; }
161a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void set_thread_id(int id) { thread_local_.thread_id_ = id; }
162a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
163a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Interface to pending exception.
164a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Object* pending_exception() {
165a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    ASSERT(has_pending_exception());
166a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return thread_local_.pending_exception_;
167a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
168a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static bool external_caught_exception() {
169a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return thread_local_.external_caught_exception_;
170a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
171a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void set_pending_exception(Object* exception) {
172a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    thread_local_.pending_exception_ = exception;
173a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
174a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void clear_pending_exception() {
175a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    thread_local_.pending_exception_ = Heap::the_hole_value();
176a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
177a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
178a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Object** pending_exception_address() {
179a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return &thread_local_.pending_exception_;
180a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
181a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static bool has_pending_exception() {
182a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return !thread_local_.pending_exception_->IsTheHole();
183a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
184a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void clear_pending_message() {
185a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    thread_local_.has_pending_message_ = false;
186a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    thread_local_.pending_message_ = NULL;
187a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    thread_local_.pending_message_obj_ = Heap::the_hole_value();
188a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    thread_local_.pending_message_script_ = NULL;
189a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
190a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static v8::TryCatch* try_catch_handler() {
191d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block    return thread_local_.TryCatchHandler();
192d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  }
193d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  static Address try_catch_handler_address() {
194d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block    return thread_local_.try_catch_handler_address();
195a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
196a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // This method is called by the api after operations that may throw
197a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // exceptions.  If an exception was thrown and not handled by an external
198a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // handler the exception is scheduled to be rethrown when we return to running
199a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // JavaScript code.  If an exception is scheduled true is returned.
200a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static bool OptionalRescheduleException(bool is_bottom_call);
201a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
202a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
203a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static bool* external_caught_exception_address() {
204a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return &thread_local_.external_caught_exception_;
205a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
206a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
207d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  static Object** scheduled_exception_address() {
208d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block    return &thread_local_.scheduled_exception_;
209d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  }
210d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block
211a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Object* scheduled_exception() {
212a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    ASSERT(has_scheduled_exception());
213a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return thread_local_.scheduled_exception_;
214a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
215a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static bool has_scheduled_exception() {
216a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return !thread_local_.scheduled_exception_->IsTheHole();
217a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
218a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void clear_scheduled_exception() {
219a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    thread_local_.scheduled_exception_ = Heap::the_hole_value();
220a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
221a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
222a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void setup_external_caught() {
223a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    thread_local_.external_caught_exception_ =
224a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block        has_pending_exception() &&
225a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block        (thread_local_.catcher_ != NULL) &&
226d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block        (try_catch_handler() == thread_local_.catcher_);
227a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
228a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
229a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Tells whether the current context has experienced an out of memory
230a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // exception.
231a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static bool is_out_of_memory();
232a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
233a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // JS execution stack (see frames.h).
234a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Address c_entry_fp(ThreadLocalTop* thread) {
235a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return thread->c_entry_fp_;
236a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
237a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Address handler(ThreadLocalTop* thread) { return thread->handler_; }
238a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
239a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static inline Address* c_entry_fp_address() {
240a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return &thread_local_.c_entry_fp_;
241a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
242a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static inline Address* handler_address() { return &thread_local_.handler_; }
243a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
244a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifdef ENABLE_LOGGING_AND_PROFILING
245a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Bottom JS entry (see StackTracer::Trace in log.cc).
246a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Address js_entry_sp(ThreadLocalTop* thread) {
247a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return thread->js_entry_sp_;
248a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
249a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static inline Address* js_entry_sp_address() {
250a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return &thread_local_.js_entry_sp_;
251a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
252a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif
253a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
254a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Generated code scratch locations.
255a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void* formal_count_address() { return &thread_local_.formal_count_; }
256a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
257a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void MarkCompactPrologue(bool is_compacting);
258a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void MarkCompactEpilogue(bool is_compacting);
259a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void MarkCompactPrologue(bool is_compacting,
260a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                  char* archived_thread_data);
261a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void MarkCompactEpilogue(bool is_compacting,
262a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                  char* archived_thread_data);
263a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void PrintCurrentStackTrace(FILE* out);
264a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void PrintStackTrace(FILE* out, char* thread_data);
265a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void PrintStack(StringStream* accumulator);
266a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void PrintStack();
267a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Handle<String> StackTrace();
268a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
269a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Returns if the top context may access the given global object. If
270a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // the result is false, the pending exception is guaranteed to be
271a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // set.
272a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static bool MayNamedAccess(JSObject* receiver,
273a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                             Object* key,
274a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                             v8::AccessType type);
275a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static bool MayIndexedAccess(JSObject* receiver,
276a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                               uint32_t index,
277a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                               v8::AccessType type);
278a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
279a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void SetFailedAccessCheckCallback(
280a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      v8::FailedAccessCheckCallback callback);
281a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void ReportFailedAccessCheck(JSObject* receiver, v8::AccessType type);
282a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
283a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Exception throwing support. The caller should use the result
284a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // of Throw() as its return value.
285a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Failure* Throw(Object* exception, MessageLocation* location = NULL);
286a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Re-throw an exception.  This involves no error reporting since
287a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // error reporting was handled when the exception was thrown
288a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // originally.
289a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Failure* ReThrow(Object* exception, MessageLocation* location = NULL);
290a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void ScheduleThrow(Object* exception);
291a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void ReportPendingMessages();
292a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Failure* ThrowIllegalOperation();
293a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
294a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Promote a scheduled exception to pending. Asserts has_scheduled_exception.
295a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Object* PromoteScheduledException();
296a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void DoThrow(Object* exception,
297a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                      MessageLocation* location,
298a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                      const char* message);
299a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static bool ShouldReturnException(bool* is_caught_externally,
300a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                    bool catchable_by_javascript);
301a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void ReportUncaughtException(Handle<Object> exception,
302a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                      MessageLocation* location,
303a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                      Handle<String> stack_trace);
304a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
305a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Attempts to compute the current source location, storing the
306a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // result in the target out parameter.
307a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void ComputeLocation(MessageLocation* target);
308a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
309a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Override command line flag.
310a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void TraceException(bool flag);
311a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
312a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Out of resource exception helpers.
313a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Failure* StackOverflow();
314a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Failure* TerminateExecution();
315a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
316a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Administration
317a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void Initialize();
318a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void TearDown();
319a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void Iterate(ObjectVisitor* v);
320a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void Iterate(ObjectVisitor* v, ThreadLocalTop* t);
321a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static char* Iterate(ObjectVisitor* v, char* t);
322a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
323a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Returns the global object of the current context. It could be
324a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // a builtin object, or a js global object.
325a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Handle<GlobalObject> global() {
326a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return Handle<GlobalObject>(context()->global());
327a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
328a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
329a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Returns the global proxy object of the current context.
330a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Object* global_proxy() {
331a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return context()->global_proxy();
332a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
333a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
334a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Returns the current global context.
335a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Handle<Context> global_context();
336a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
337a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Returns the global context of the calling JavaScript code.  That
338a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // is, the global context of the top-most JavaScript frame.
339a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Handle<Context> GetCallingGlobalContext();
340a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
341a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Handle<JSBuiltinsObject> builtins() {
342a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return Handle<JSBuiltinsObject>(thread_local_.context_->builtins());
343a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
344a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
345402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  static bool CanHaveSpecialFunctions(JSObject* object);
346a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Object* LookupSpecialFunction(JSObject* receiver,
347a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                       JSObject* prototype,
348a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                       JSFunction* value);
349a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
350a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void RegisterTryCatchHandler(v8::TryCatch* that);
351a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void UnregisterTryCatchHandler(v8::TryCatch* that);
352a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
353a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define TOP_GLOBAL_CONTEXT_FIELD_ACCESSOR(index, type, name)  \
354a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Handle<type> name() {                                \
355a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return Handle<type>(context()->global_context()->name()); \
356a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
357a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  GLOBAL_CONTEXT_FIELDS(TOP_GLOBAL_CONTEXT_FIELD_ACCESSOR)
358a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#undef TOP_GLOBAL_CONTEXT_FIELD_ACCESSOR
359a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
360a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static inline ThreadLocalTop* GetCurrentThread() { return &thread_local_; }
361a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static int ArchiveSpacePerThread() { return sizeof(ThreadLocalTop); }
362a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static char* ArchiveThread(char* to);
363a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static char* RestoreThread(char* from);
364a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void FreeThreadResources() { thread_local_.Free(); }
365a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
366a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const char* kStackOverflowMessage;
367a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
368a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block private:
369a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // The context that initiated this JS execution.
370a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static ThreadLocalTop thread_local_;
371a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void InitializeThreadLocal();
372a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void PrintStackTrace(FILE* out, ThreadLocalTop* thread);
373a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void MarkCompactPrologue(bool is_compacting,
374a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                  ThreadLocalTop* archived_thread_data);
375a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void MarkCompactEpilogue(bool is_compacting,
376a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                  ThreadLocalTop* archived_thread_data);
377a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
378a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Debug.
379a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Mutex for serializing access to break control structures.
380a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Mutex* break_access_;
381a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
382a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  friend class SaveContext;
383a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  friend class AssertNoContextChange;
384a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  friend class ExecutionAccess;
385a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
386a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static void FillCache();
387a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
388a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
389a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
390a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// If the GCC version is 4.1.x or 4.2.x an additional field is added to the
391a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// class as a work around for a bug in the generated code found with these
392a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// versions of GCC. See V8 issue 122 for details.
393a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass SaveContext BASE_EMBEDDED {
394a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
395a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  SaveContext()
396a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      : context_(Top::context()),
397a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#if __GNUC_VERSION__ >= 40100 && __GNUC_VERSION__ < 40300
398a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block        dummy_(Top::context()),
399a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif
400a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block        prev_(Top::save_context()) {
401a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    Top::set_save_context(this);
402a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
403a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    // If there is no JS frame under the current C frame, use the value 0.
404a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    JavaScriptFrameIterator it;
405a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    js_sp_ = it.done() ? 0 : it.frame()->sp();
406a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
407a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
408a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  ~SaveContext() {
409a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    Top::set_context(*context_);
410a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    Top::set_save_context(prev_);
411a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
412a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
413a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Handle<Context> context() { return context_; }
414a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  SaveContext* prev() { return prev_; }
415a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
416a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Returns true if this save context is below a given JavaScript frame.
417a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  bool below(JavaScriptFrame* frame) {
418a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return (js_sp_ == 0) || (frame->sp() < js_sp_);
419a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
420a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
421a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block private:
422a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Handle<Context> context_;
423a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#if __GNUC_VERSION__ >= 40100 && __GNUC_VERSION__ < 40300
424a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Handle<Context> dummy_;
425a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif
426a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  SaveContext* prev_;
427a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Address js_sp_;  // The top JS frame's sp when saving context.
428a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
429a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
430a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
431a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass AssertNoContextChange BASE_EMBEDDED {
432a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifdef DEBUG
433a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
434a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  AssertNoContextChange() :
435a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      context_(Top::context()) {
436a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
437a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
438a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  ~AssertNoContextChange() {
439a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    ASSERT(Top::context() == *context_);
440a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
441a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
442a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block private:
443a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  HandleScope scope_;
444a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Handle<Context> context_;
445a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#else
446a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
447a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  AssertNoContextChange() { }
448a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif
449a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
450a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
451a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
452a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass ExecutionAccess BASE_EMBEDDED {
453a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
454a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  ExecutionAccess();
455a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  ~ExecutionAccess();
456a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
457a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
458a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} }  // namespace v8::internal
459a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
460a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif  // V8_TOP_H_
461