Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: src/isolate.h

Issue 10910161: Partial ia32 implementation of optimized try/catch (by Kevin Millikin) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed build. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/isolate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 int pending_message_start_pos_; 244 int pending_message_start_pos_;
245 int pending_message_end_pos_; 245 int pending_message_end_pos_;
246 // Use a separate value for scheduled exceptions to preserve the 246 // Use a separate value for scheduled exceptions to preserve the
247 // invariants that hold about pending_exception. We may want to 247 // invariants that hold about pending_exception. We may want to
248 // unify them later. 248 // unify them later.
249 MaybeObject* scheduled_exception_; 249 MaybeObject* scheduled_exception_;
250 bool external_caught_exception_; 250 bool external_caught_exception_;
251 SaveContext* save_context_; 251 SaveContext* save_context_;
252 v8::TryCatch* catcher_; 252 v8::TryCatch* catcher_;
253 253
254 // Fields for handling try-catch statements in optimized code.
255 byte* optimized_handler_patch_buffer_;
256 MaybeObject* optimized_pending_exception_;
257 int optimized_handler_handler_index_;
258 int optimized_handler_deopt_index_;
259 int optimized_handler_frame_pc_offset_;
260
254 // Stack. 261 // Stack.
255 Address c_entry_fp_; // the frame pointer of the top c entry frame 262 Address c_entry_fp_; // the frame pointer of the top c entry frame
256 Address handler_; // try-blocks are chained through the stack 263 Address handler_; // try-blocks are chained through the stack
257 264
258 #ifdef USE_SIMULATOR 265 #ifdef USE_SIMULATOR
259 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) 266 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS)
260 Simulator* simulator_; 267 Simulator* simulator_;
261 #endif 268 #endif
262 #endif // USE_SIMULATOR 269 #endif // USE_SIMULATOR
263 270
264 Address js_entry_sp_; // the stack pointer of the bottom JS entry frame 271 Address js_entry_sp_; // the stack pointer of the bottom JS entry frame
265 Address external_callback_; // the external callback we're currently in 272 Address external_callback_; // the external callback we're currently in
266 StateTag current_vm_state_; 273 StateTag current_vm_state_;
267 274
268 // Generated code scratch locations. 275 // Generated code scratch locations.
269 int32_t formal_count_; 276 int32_t formal_count_;
270 277
271 // Call back function to report unsafe JS accesses. 278 // Call back function to report unsafe JS accesses.
272 v8::FailedAccessCheckCallback failed_access_check_callback_; 279 v8::FailedAccessCheckCallback failed_access_check_callback_;
273 280
274 // Head of the list of live LookupResults. 281 // Head of the list of live LookupResults.
275 LookupResult* top_lookup_result_; 282 LookupResult* top_lookup_result_;
276 283
277 // Whether out of memory exceptions should be ignored. 284 // Whether out of memory exceptions should be ignored.
278 bool ignore_out_of_memory_; 285 bool ignore_out_of_memory_;
279 286
287 int thread_id() { return thread_id_.ToInteger(); }
288
280 private: 289 private:
281 void InitializeInternal(); 290 void InitializeInternal();
282 291
283 Address try_catch_handler_address_; 292 Address try_catch_handler_address_;
284 }; 293 };
285 294
286 295
287 #ifdef ENABLE_DEBUGGER_SUPPORT 296 #ifdef ENABLE_DEBUGGER_SUPPORT
288 297
289 #define ISOLATE_DEBUGGER_INIT_LIST(V) \ 298 #define ISOLATE_DEBUGGER_INIT_LIST(V) \
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 Address get_address_from_id(AddressId id); 526 Address get_address_from_id(AddressId id);
518 527
519 // Access to top context (where the current function object was created). 528 // Access to top context (where the current function object was created).
520 Context* context() { return thread_local_top_.context_; } 529 Context* context() { return thread_local_top_.context_; }
521 void set_context(Context* context) { 530 void set_context(Context* context) {
522 ASSERT(context == NULL || context->IsContext()); 531 ASSERT(context == NULL || context->IsContext());
523 thread_local_top_.context_ = context; 532 thread_local_top_.context_ = context;
524 } 533 }
525 Context** context_address() { return &thread_local_top_.context_; } 534 Context** context_address() { return &thread_local_top_.context_; }
526 535
527 SaveContext* save_context() {return thread_local_top_.save_context_; } 536 SaveContext* save_context() { return thread_local_top_.save_context_; }
528 void set_save_context(SaveContext* save) { 537 void set_save_context(SaveContext* save) {
529 thread_local_top_.save_context_ = save; 538 thread_local_top_.save_context_ = save;
530 } 539 }
531 540
532 // Access to the map of "new Object()". 541 // Access to the map of "new Object()".
533 Map* empty_object_map() { 542 Map* empty_object_map() {
534 return context()->native_context()->object_function()->map(); 543 return context()->native_context()->object_function()->map();
535 } 544 }
536 545
537 // Access to current thread id. 546 // Access to current thread id.
538 ThreadId thread_id() { return thread_local_top_.thread_id_; } 547 ThreadId thread_id() { return thread_local_top_.thread_id_; }
539 void set_thread_id(ThreadId id) { thread_local_top_.thread_id_ = id; } 548 void set_thread_id(ThreadId id) { thread_local_top_.thread_id_ = id; }
540 549
541 // Interface to pending exception. 550 // Interface to pending exception.
542 MaybeObject* pending_exception() { 551 MaybeObject* pending_exception() {
543 ASSERT(has_pending_exception()); 552 ASSERT(has_pending_exception());
544 return thread_local_top_.pending_exception_; 553 return thread_local_top_.pending_exception_;
545 } 554 }
546 bool external_caught_exception() { 555 bool external_caught_exception() {
547 return thread_local_top_.external_caught_exception_; 556 return thread_local_top_.external_caught_exception_;
548 } 557 }
549 void set_external_caught_exception(bool value) { 558 void set_external_caught_exception(bool value) {
550 thread_local_top_.external_caught_exception_ = value; 559 thread_local_top_.external_caught_exception_ = value;
551 } 560 }
552 void set_pending_exception(MaybeObject* exception) { 561 void set_pending_exception(MaybeObject* exception) {
553 thread_local_top_.pending_exception_ = exception; 562 thread_local_top_.pending_exception_ = exception;
554 } 563 }
555 void clear_pending_exception() { 564 void clear_pending_exception() {
556 thread_local_top_.pending_exception_ = heap_.the_hole_value(); 565 thread_local_top_.pending_exception_ = heap_.the_hole_value();
566
567 if (is_handling_optimized_catch_statement()) {
568 ClearOptimizedHandlerByAPI();
569 }
557 } 570 }
558 MaybeObject** pending_exception_address() { 571 MaybeObject** pending_exception_address() {
559 return &thread_local_top_.pending_exception_; 572 return &thread_local_top_.pending_exception_;
560 } 573 }
561 bool has_pending_exception() { 574 bool has_pending_exception() {
562 return !thread_local_top_.pending_exception_->IsTheHole(); 575 return !thread_local_top_.pending_exception_->IsTheHole();
563 } 576 }
564 void clear_pending_message() { 577 void clear_pending_message() {
565 thread_local_top_.has_pending_message_ = false; 578 thread_local_top_.has_pending_message_ = false;
566 thread_local_top_.pending_message_obj_ = heap_.the_hole_value(); 579 thread_local_top_.pending_message_obj_ = heap_.the_hole_value();
567 thread_local_top_.pending_message_script_ = NULL; 580 thread_local_top_.pending_message_script_ = NULL;
568 } 581 }
569 v8::TryCatch* try_catch_handler() { 582 v8::TryCatch* try_catch_handler() {
570 return thread_local_top_.TryCatchHandler(); 583 return thread_local_top_.TryCatchHandler();
571 } 584 }
572 Address try_catch_handler_address() { 585 Address try_catch_handler_address() {
573 return thread_local_top_.try_catch_handler_address(); 586 return thread_local_top_.try_catch_handler_address();
574 } 587 }
575 bool* external_caught_exception_address() { 588 bool* external_caught_exception_address() {
576 return &thread_local_top_.external_caught_exception_; 589 return &thread_local_top_.external_caught_exception_;
577 } 590 }
578 v8::TryCatch* catcher() { 591 v8::TryCatch* catcher() {
579 return thread_local_top_.catcher_; 592 return thread_local_top_.catcher_;
580 } 593 }
581 void set_catcher(v8::TryCatch* catcher) { 594 void set_catcher(v8::TryCatch* catcher) {
582 thread_local_top_.catcher_ = catcher; 595 thread_local_top_.catcher_ = catcher;
583 } 596 }
584 597
598 // Interface for supporting try-catch statements in optimized code.
599 bool is_handling_optimized_catch_statement() {
600 return thread_local_top_.optimized_handler_handler_index_ != -1;
601 }
602 byte* optimized_handler_patch_buffer() {
603 return thread_local_top_.optimized_handler_patch_buffer_;
604 }
605 void set_optimized_handler_patch_buffer(Address patch_address,
606 int patch_size) {
607 ASSERT(thread_local_top_.optimized_handler_patch_buffer_ == NULL);
608 thread_local_top_.optimized_handler_patch_buffer_ = new byte[patch_size];
609 memcpy(thread_local_top_.optimized_handler_patch_buffer_,
610 patch_address, patch_size);
611 }
612 void clear_optimized_handler_patch_buffer() {
613 ASSERT(thread_local_top_.optimized_handler_patch_buffer_ != NULL);
614 delete[] thread_local_top_.optimized_handler_patch_buffer_;
615 thread_local_top_.optimized_handler_patch_buffer_ = NULL;
616 }
617 MaybeObject* optimized_pending_exception() {
618 return thread_local_top_.optimized_pending_exception_;
619 }
620 void set_optimized_pending_exception(MaybeObject* v) {
621 thread_local_top_.optimized_pending_exception_ = v;
622 }
623 void clear_optimized_pending_exception() {
624 thread_local_top_.optimized_pending_exception_ = NULL;
625 }
626 int optimized_handler_handler_index() {
627 return thread_local_top_.optimized_handler_handler_index_;
628 }
629 void set_optimized_handler_handler_index(int v) {
630 ASSERT(thread_local_top_.optimized_handler_handler_index_ == -1);
631 thread_local_top_.optimized_handler_handler_index_ = v;
632 }
633 void clear_optimized_handler_handler_index() {
634 ASSERT(thread_local_top_.optimized_handler_handler_index_ != -1);
635 thread_local_top_.optimized_handler_handler_index_ = -1;
636 }
637 int optimized_handler_deopt_index() {
638 return thread_local_top_.optimized_handler_deopt_index_;
639 }
640 void set_optimized_handler_deopt_index(int v) {
641 ASSERT(thread_local_top_.optimized_handler_deopt_index_ == -1);
642 thread_local_top_.optimized_handler_deopt_index_ = v;
643 }
644 void clear_optimized_handler_deopt_index() {
645 ASSERT(thread_local_top_.optimized_handler_deopt_index_ != -1);
646 thread_local_top_.optimized_handler_deopt_index_ = -1;
647 }
648 int optimized_handler_frame_pc_offset() {
649 return thread_local_top_.optimized_handler_frame_pc_offset_;
650 }
651 void set_optimized_handler_frame_pc_offset(int v) {
652 ASSERT(thread_local_top_.optimized_handler_frame_pc_offset_ == -1);
653 thread_local_top_.optimized_handler_frame_pc_offset_ = v;
654 }
655 void clear_optimized_handler_frame_pc_offset() {
656 ASSERT(thread_local_top_.optimized_handler_frame_pc_offset_ != -1);
657 thread_local_top_.optimized_handler_frame_pc_offset_ = -1;
658 }
659
660
585 MaybeObject** scheduled_exception_address() { 661 MaybeObject** scheduled_exception_address() {
586 return &thread_local_top_.scheduled_exception_; 662 return &thread_local_top_.scheduled_exception_;
587 } 663 }
588 664
589 Address pending_message_obj_address() { 665 Address pending_message_obj_address() {
590 return reinterpret_cast<Address>(&thread_local_top_.pending_message_obj_); 666 return reinterpret_cast<Address>(&thread_local_top_.pending_message_obj_);
591 } 667 }
592 668
593 Address has_pending_message_address() { 669 Address has_pending_message_address() {
594 return reinterpret_cast<Address>(&thread_local_top_.has_pending_message_); 670 return reinterpret_cast<Address>(&thread_local_top_.has_pending_message_);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 Failure* ThrowIllegalOperation(); 818 Failure* ThrowIllegalOperation();
743 819
744 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. 820 // Promote a scheduled exception to pending. Asserts has_scheduled_exception.
745 Failure* PromoteScheduledException(); 821 Failure* PromoteScheduledException();
746 void DoThrow(Object* exception, MessageLocation* location); 822 void DoThrow(Object* exception, MessageLocation* location);
747 // Checks if exception should be reported and finds out if it's 823 // Checks if exception should be reported and finds out if it's
748 // caught externally. 824 // caught externally.
749 bool ShouldReportException(bool* can_be_caught_externally, 825 bool ShouldReportException(bool* can_be_caught_externally,
750 bool catchable_by_javascript); 826 bool catchable_by_javascript);
751 827
828 // The temporary optimized handler state is used by the deoptimizer when
829 // catching exceptions in optimized code.
830 void PrepareForOptimizedHandler();
831 void ClearOptimizedHandlerByDeopt(Code* optimized_code);
832 void ClearOptimizedHandlerByAPI();
833
752 // Attempts to compute the current source location, storing the 834 // Attempts to compute the current source location, storing the
753 // result in the target out parameter. 835 // result in the target out parameter.
754 void ComputeLocation(MessageLocation* target); 836 void ComputeLocation(MessageLocation* target);
755 837
756 // Override command line flag. 838 // Override command line flag.
757 void TraceException(bool flag); 839 void TraceException(bool flag);
758 840
759 // Out of resource exception helpers. 841 // Out of resource exception helpers.
760 Failure* StackOverflow(); 842 Failure* StackOverflow();
761 Failure* TerminateExecution(); 843 Failure* TerminateExecution();
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 1529
1448 // Mark the native context with out of memory. 1530 // Mark the native context with out of memory.
1449 inline void Context::mark_out_of_memory() { 1531 inline void Context::mark_out_of_memory() {
1450 native_context()->set_out_of_memory(HEAP->true_value()); 1532 native_context()->set_out_of_memory(HEAP->true_value());
1451 } 1533 }
1452 1534
1453 1535
1454 } } // namespace v8::internal 1536 } } // namespace v8::internal
1455 1537
1456 #endif // V8_ISOLATE_H_ 1538 #endif // V8_ISOLATE_H_
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698