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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 // versions of GCC. See V8 issue 122 for details. | 305 // versions of GCC. See V8 issue 122 for details. |
306 class SaveContext BASE_EMBEDDED { | 306 class SaveContext BASE_EMBEDDED { |
307 public: | 307 public: |
308 SaveContext() : | 308 SaveContext() : |
309 context_(Top::context()), | 309 context_(Top::context()), |
310 #if __GNUC_VERSION__ >= 40100 && __GNUC_VERSION__ < 40300 | 310 #if __GNUC_VERSION__ >= 40100 && __GNUC_VERSION__ < 40300 |
311 dummy_(Top::context()), | 311 dummy_(Top::context()), |
312 #endif | 312 #endif |
313 prev_(Top::save_context()) { | 313 prev_(Top::save_context()) { |
314 Top::set_save_context(this); | 314 Top::set_save_context(this); |
| 315 |
| 316 // If there is no JS frame under the current C frame, use the value 0. |
| 317 JavaScriptFrameIterator it; |
| 318 js_sp_ = it.done() ? 0 : it.frame()->sp(); |
315 } | 319 } |
316 | 320 |
317 ~SaveContext() { | 321 ~SaveContext() { |
318 Top::set_context(*context_); | 322 Top::set_context(*context_); |
319 Top::set_save_context(prev_); | 323 Top::set_save_context(prev_); |
320 } | 324 } |
321 | 325 |
322 Handle<Context> context() { return context_; } | 326 Handle<Context> context() { return context_; } |
323 SaveContext* prev() { return prev_; } | 327 SaveContext* prev() { return prev_; } |
324 | 328 |
| 329 // Returns true if this save context is below a given JavaScript frame. |
| 330 bool below(JavaScriptFrame* frame) { |
| 331 return (js_sp_ == 0) || (frame->sp() < js_sp_); |
| 332 } |
| 333 |
325 private: | 334 private: |
326 Handle<Context> context_; | 335 Handle<Context> context_; |
327 #if __GNUC_VERSION__ >= 40100 && __GNUC_VERSION__ < 40300 | 336 #if __GNUC_VERSION__ >= 40100 && __GNUC_VERSION__ < 40300 |
328 Handle<Context> dummy_; | 337 Handle<Context> dummy_; |
329 #endif | 338 #endif |
330 SaveContext* prev_; | 339 SaveContext* prev_; |
| 340 Address js_sp_; // The top JS frame's sp when saving context. |
331 }; | 341 }; |
332 | 342 |
333 | 343 |
334 class AssertNoContextChange BASE_EMBEDDED { | 344 class AssertNoContextChange BASE_EMBEDDED { |
335 #ifdef DEBUG | 345 #ifdef DEBUG |
336 public: | 346 public: |
337 AssertNoContextChange() : | 347 AssertNoContextChange() : |
338 context_(Top::context()) { | 348 context_(Top::context()) { |
339 } | 349 } |
340 | 350 |
(...skipping 13 matching lines...) Expand all Loading... |
354 | 364 |
355 class ExecutionAccess BASE_EMBEDDED { | 365 class ExecutionAccess BASE_EMBEDDED { |
356 public: | 366 public: |
357 ExecutionAccess(); | 367 ExecutionAccess(); |
358 ~ExecutionAccess(); | 368 ~ExecutionAccess(); |
359 }; | 369 }; |
360 | 370 |
361 } } // namespace v8::internal | 371 } } // namespace v8::internal |
362 | 372 |
363 #endif // V8_TOP_H_ | 373 #endif // V8_TOP_H_ |
OLD | NEW |