OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 11 matching lines...) Expand all Loading... |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_TOP_H_ | 28 #ifndef V8_TOP_H_ |
29 #define V8_TOP_H_ | 29 #define V8_TOP_H_ |
30 | 30 |
31 #include "frames-inl.h" | 31 #include "frames-inl.h" |
| 32 #include "simulator.h" |
32 | 33 |
33 namespace v8 { | 34 namespace v8 { |
34 namespace internal { | 35 namespace internal { |
35 | 36 |
36 | 37 |
37 #define RETURN_IF_SCHEDULED_EXCEPTION() \ | 38 #define RETURN_IF_SCHEDULED_EXCEPTION() \ |
38 if (Top::has_scheduled_exception()) return Top::PromoteScheduledException() | 39 if (Top::has_scheduled_exception()) return Top::PromoteScheduledException() |
39 | 40 |
40 // Top has static variables used for JavaScript execution. | 41 // Top has static variables used for JavaScript execution. |
41 | 42 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 void Free() { | 78 void Free() { |
78 ASSERT(!has_pending_message_); | 79 ASSERT(!has_pending_message_); |
79 ASSERT(!external_caught_exception_); | 80 ASSERT(!external_caught_exception_); |
80 ASSERT(try_catch_handler_address_ == NULL); | 81 ASSERT(try_catch_handler_address_ == NULL); |
81 } | 82 } |
82 | 83 |
83 // The context where the current execution method is created and for variable | 84 // The context where the current execution method is created and for variable |
84 // lookups. | 85 // lookups. |
85 Context* context_; | 86 Context* context_; |
86 int thread_id_; | 87 int thread_id_; |
87 Object* pending_exception_; | 88 MaybeObject* pending_exception_; |
88 bool has_pending_message_; | 89 bool has_pending_message_; |
89 const char* pending_message_; | 90 const char* pending_message_; |
90 Object* pending_message_obj_; | 91 Object* pending_message_obj_; |
91 Script* pending_message_script_; | 92 Script* pending_message_script_; |
92 int pending_message_start_pos_; | 93 int pending_message_start_pos_; |
93 int pending_message_end_pos_; | 94 int pending_message_end_pos_; |
94 // Use a separate value for scheduled exceptions to preserve the | 95 // Use a separate value for scheduled exceptions to preserve the |
95 // invariants that hold about pending_exception. We may want to | 96 // invariants that hold about pending_exception. We may want to |
96 // unify them later. | 97 // unify them later. |
97 Object* scheduled_exception_; | 98 MaybeObject* scheduled_exception_; |
98 bool external_caught_exception_; | 99 bool external_caught_exception_; |
99 SaveContext* save_context_; | 100 SaveContext* save_context_; |
100 v8::TryCatch* catcher_; | 101 v8::TryCatch* catcher_; |
101 | 102 |
102 // Stack. | 103 // Stack. |
103 Address c_entry_fp_; // the frame pointer of the top c entry frame | 104 Address c_entry_fp_; // the frame pointer of the top c entry frame |
104 Address handler_; // try-blocks are chained through the stack | 105 Address handler_; // try-blocks are chained through the stack |
105 | 106 |
| 107 #ifdef USE_SIMULATOR |
| 108 assembler::arm::Simulator* simulator_; |
| 109 #endif // USE_SIMULATOR |
| 110 |
106 #ifdef ENABLE_LOGGING_AND_PROFILING | 111 #ifdef ENABLE_LOGGING_AND_PROFILING |
107 Address js_entry_sp_; // the stack pointer of the bottom js entry frame | 112 Address js_entry_sp_; // the stack pointer of the bottom js entry frame |
108 #endif | 113 #endif |
109 | 114 |
110 #ifdef ENABLE_VMSTATE_TRACKING | 115 #ifdef ENABLE_VMSTATE_TRACKING |
111 VMState* current_vm_state_; | 116 VMState* current_vm_state_; |
112 #endif | 117 #endif |
113 | 118 |
114 // Generated code scratch locations. | 119 // Generated code scratch locations. |
115 int32_t formal_count_; | 120 int32_t formal_count_; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 static SaveContext* save_context() {return thread_local_.save_context_; } | 163 static SaveContext* save_context() {return thread_local_.save_context_; } |
159 static void set_save_context(SaveContext* save) { | 164 static void set_save_context(SaveContext* save) { |
160 thread_local_.save_context_ = save; | 165 thread_local_.save_context_ = save; |
161 } | 166 } |
162 | 167 |
163 // Access to current thread id. | 168 // Access to current thread id. |
164 static int thread_id() { return thread_local_.thread_id_; } | 169 static int thread_id() { return thread_local_.thread_id_; } |
165 static void set_thread_id(int id) { thread_local_.thread_id_ = id; } | 170 static void set_thread_id(int id) { thread_local_.thread_id_ = id; } |
166 | 171 |
167 // Interface to pending exception. | 172 // Interface to pending exception. |
168 static Object* pending_exception() { | 173 static MaybeObject* pending_exception() { |
169 ASSERT(has_pending_exception()); | 174 ASSERT(has_pending_exception()); |
170 return thread_local_.pending_exception_; | 175 return thread_local_.pending_exception_; |
171 } | 176 } |
172 static bool external_caught_exception() { | 177 static bool external_caught_exception() { |
173 return thread_local_.external_caught_exception_; | 178 return thread_local_.external_caught_exception_; |
174 } | 179 } |
175 static void set_pending_exception(Object* exception) { | 180 static void set_pending_exception(MaybeObject* exception) { |
176 thread_local_.pending_exception_ = exception; | 181 thread_local_.pending_exception_ = exception; |
177 } | 182 } |
178 static void clear_pending_exception() { | 183 static void clear_pending_exception() { |
179 thread_local_.pending_exception_ = Heap::the_hole_value(); | 184 thread_local_.pending_exception_ = Heap::the_hole_value(); |
180 } | 185 } |
181 | 186 |
182 static Object** pending_exception_address() { | 187 static MaybeObject** pending_exception_address() { |
183 return &thread_local_.pending_exception_; | 188 return &thread_local_.pending_exception_; |
184 } | 189 } |
185 static bool has_pending_exception() { | 190 static bool has_pending_exception() { |
186 return !thread_local_.pending_exception_->IsTheHole(); | 191 return !thread_local_.pending_exception_->IsTheHole(); |
187 } | 192 } |
188 static void clear_pending_message() { | 193 static void clear_pending_message() { |
189 thread_local_.has_pending_message_ = false; | 194 thread_local_.has_pending_message_ = false; |
190 thread_local_.pending_message_ = NULL; | 195 thread_local_.pending_message_ = NULL; |
191 thread_local_.pending_message_obj_ = Heap::the_hole_value(); | 196 thread_local_.pending_message_obj_ = Heap::the_hole_value(); |
192 thread_local_.pending_message_script_ = NULL; | 197 thread_local_.pending_message_script_ = NULL; |
193 } | 198 } |
194 static v8::TryCatch* try_catch_handler() { | 199 static v8::TryCatch* try_catch_handler() { |
195 return thread_local_.TryCatchHandler(); | 200 return thread_local_.TryCatchHandler(); |
196 } | 201 } |
197 static Address try_catch_handler_address() { | 202 static Address try_catch_handler_address() { |
198 return thread_local_.try_catch_handler_address(); | 203 return thread_local_.try_catch_handler_address(); |
199 } | 204 } |
200 // This method is called by the api after operations that may throw | 205 // This method is called by the api after operations that may throw |
201 // exceptions. If an exception was thrown and not handled by an external | 206 // exceptions. If an exception was thrown and not handled by an external |
202 // handler the exception is scheduled to be rethrown when we return to running | 207 // handler the exception is scheduled to be rethrown when we return to running |
203 // JavaScript code. If an exception is scheduled true is returned. | 208 // JavaScript code. If an exception is scheduled true is returned. |
204 static bool OptionalRescheduleException(bool is_bottom_call); | 209 static bool OptionalRescheduleException(bool is_bottom_call); |
205 | 210 |
206 | 211 |
207 static bool* external_caught_exception_address() { | 212 static bool* external_caught_exception_address() { |
208 return &thread_local_.external_caught_exception_; | 213 return &thread_local_.external_caught_exception_; |
209 } | 214 } |
210 | 215 |
211 static Object** scheduled_exception_address() { | 216 static MaybeObject** scheduled_exception_address() { |
212 return &thread_local_.scheduled_exception_; | 217 return &thread_local_.scheduled_exception_; |
213 } | 218 } |
214 | 219 |
215 static Object* scheduled_exception() { | 220 static MaybeObject* scheduled_exception() { |
216 ASSERT(has_scheduled_exception()); | 221 ASSERT(has_scheduled_exception()); |
217 return thread_local_.scheduled_exception_; | 222 return thread_local_.scheduled_exception_; |
218 } | 223 } |
219 static bool has_scheduled_exception() { | 224 static bool has_scheduled_exception() { |
220 return !thread_local_.scheduled_exception_->IsTheHole(); | 225 return !thread_local_.scheduled_exception_->IsTheHole(); |
221 } | 226 } |
222 static void clear_scheduled_exception() { | 227 static void clear_scheduled_exception() { |
223 thread_local_.scheduled_exception_ = Heap::the_hole_value(); | 228 thread_local_.scheduled_exception_ = Heap::the_hole_value(); |
224 } | 229 } |
225 | 230 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 static void SetFailedAccessCheckCallback( | 300 static void SetFailedAccessCheckCallback( |
296 v8::FailedAccessCheckCallback callback); | 301 v8::FailedAccessCheckCallback callback); |
297 static void ReportFailedAccessCheck(JSObject* receiver, v8::AccessType type); | 302 static void ReportFailedAccessCheck(JSObject* receiver, v8::AccessType type); |
298 | 303 |
299 // Exception throwing support. The caller should use the result | 304 // Exception throwing support. The caller should use the result |
300 // of Throw() as its return value. | 305 // of Throw() as its return value. |
301 static Failure* Throw(Object* exception, MessageLocation* location = NULL); | 306 static Failure* Throw(Object* exception, MessageLocation* location = NULL); |
302 // Re-throw an exception. This involves no error reporting since | 307 // Re-throw an exception. This involves no error reporting since |
303 // error reporting was handled when the exception was thrown | 308 // error reporting was handled when the exception was thrown |
304 // originally. | 309 // originally. |
305 static Failure* ReThrow(Object* exception, MessageLocation* location = NULL); | 310 static Failure* ReThrow(MaybeObject* exception, |
| 311 MessageLocation* location = NULL); |
306 static void ScheduleThrow(Object* exception); | 312 static void ScheduleThrow(Object* exception); |
307 static void ReportPendingMessages(); | 313 static void ReportPendingMessages(); |
308 static Failure* ThrowIllegalOperation(); | 314 static Failure* ThrowIllegalOperation(); |
309 | 315 |
310 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. | 316 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. |
311 static Object* PromoteScheduledException(); | 317 static Failure* PromoteScheduledException(); |
312 static void DoThrow(Object* exception, | 318 static void DoThrow(MaybeObject* exception, |
313 MessageLocation* location, | 319 MessageLocation* location, |
314 const char* message); | 320 const char* message); |
315 static bool ShouldReturnException(bool* is_caught_externally, | 321 static bool ShouldReturnException(bool* is_caught_externally, |
316 bool catchable_by_javascript); | 322 bool catchable_by_javascript); |
317 | 323 |
318 // Attempts to compute the current source location, storing the | 324 // Attempts to compute the current source location, storing the |
319 // result in the target out parameter. | 325 // result in the target out parameter. |
320 static void ComputeLocation(MessageLocation* target); | 326 static void ComputeLocation(MessageLocation* target); |
321 | 327 |
322 // Override command line flag. | 328 // Override command line flag. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 | 467 |
462 class ExecutionAccess BASE_EMBEDDED { | 468 class ExecutionAccess BASE_EMBEDDED { |
463 public: | 469 public: |
464 ExecutionAccess(); | 470 ExecutionAccess(); |
465 ~ExecutionAccess(); | 471 ~ExecutionAccess(); |
466 }; | 472 }; |
467 | 473 |
468 } } // namespace v8::internal | 474 } } // namespace v8::internal |
469 | 475 |
470 #endif // V8_TOP_H_ | 476 #endif // V8_TOP_H_ |
OLD | NEW |