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

Side by Side Diff: src/isolate.h

Issue 6685087: Make exception thrown via v8 public API propagate to v8::TryCatch as JS thrown exceptions do. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Next round Created 9 years, 9 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
« src/api.cc ('K') | « src/handles.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 const char* pending_message_; 180 const char* pending_message_;
181 Object* pending_message_obj_; 181 Object* pending_message_obj_;
182 Script* pending_message_script_; 182 Script* pending_message_script_;
183 int pending_message_start_pos_; 183 int pending_message_start_pos_;
184 int pending_message_end_pos_; 184 int pending_message_end_pos_;
185 // Use a separate value for scheduled exceptions to preserve the 185 // Use a separate value for scheduled exceptions to preserve the
186 // invariants that hold about pending_exception. We may want to 186 // invariants that hold about pending_exception. We may want to
187 // unify them later. 187 // unify them later.
188 MaybeObject* scheduled_exception_; 188 MaybeObject* scheduled_exception_;
189 bool external_caught_exception_; 189 bool external_caught_exception_;
190 // True if unhandled message is being currently reported by
191 // MessageHandler::ReportMessage.
192 bool in_exception_reporting_;
190 SaveContext* save_context_; 193 SaveContext* save_context_;
191 v8::TryCatch* catcher_; 194 v8::TryCatch* catcher_;
192 195
193 // Stack. 196 // Stack.
194 Address c_entry_fp_; // the frame pointer of the top c entry frame 197 Address c_entry_fp_; // the frame pointer of the top c entry frame
195 Address handler_; // try-blocks are chained through the stack 198 Address handler_; // try-blocks are chained through the stack
196 199
197 #ifdef USE_SIMULATOR 200 #ifdef USE_SIMULATOR
198 #ifdef V8_TARGET_ARCH_ARM 201 #ifdef V8_TARGET_ARCH_ARM
199 Simulator* simulator_; 202 Simulator* simulator_;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 void set_thread_id(int id) { thread_local_top_.thread_id_ = id; } 486 void set_thread_id(int id) { thread_local_top_.thread_id_ = id; }
484 487
485 // Interface to pending exception. 488 // Interface to pending exception.
486 MaybeObject* pending_exception() { 489 MaybeObject* pending_exception() {
487 ASSERT(has_pending_exception()); 490 ASSERT(has_pending_exception());
488 return thread_local_top_.pending_exception_; 491 return thread_local_top_.pending_exception_;
489 } 492 }
490 bool external_caught_exception() { 493 bool external_caught_exception() {
491 return thread_local_top_.external_caught_exception_; 494 return thread_local_top_.external_caught_exception_;
492 } 495 }
496 void set_external_caught_exception(bool value) {
497 thread_local_top_.external_caught_exception_ = value;
498 }
493 void set_pending_exception(MaybeObject* exception) { 499 void set_pending_exception(MaybeObject* exception) {
494 thread_local_top_.pending_exception_ = exception; 500 thread_local_top_.pending_exception_ = exception;
495 } 501 }
496 void clear_pending_exception() { 502 void clear_pending_exception() {
497 thread_local_top_.pending_exception_ = heap_.the_hole_value(); 503 thread_local_top_.pending_exception_ = heap_.the_hole_value();
498 } 504 }
499 MaybeObject** pending_exception_address() { 505 MaybeObject** pending_exception_address() {
500 return &thread_local_top_.pending_exception_; 506 return &thread_local_top_.pending_exception_;
501 } 507 }
502 bool has_pending_exception() { 508 bool has_pending_exception() {
503 return !thread_local_top_.pending_exception_->IsTheHole(); 509 return !thread_local_top_.pending_exception_->IsTheHole();
504 } 510 }
505 void clear_pending_message() { 511 void clear_pending_message() {
506 thread_local_top_.has_pending_message_ = false; 512 thread_local_top_.has_pending_message_ = false;
507 thread_local_top_.pending_message_ = NULL; 513 thread_local_top_.pending_message_ = NULL;
508 thread_local_top_.pending_message_obj_ = heap_.the_hole_value(); 514 thread_local_top_.pending_message_obj_ = heap_.the_hole_value();
509 thread_local_top_.pending_message_script_ = NULL; 515 thread_local_top_.pending_message_script_ = NULL;
510 } 516 }
511 v8::TryCatch* try_catch_handler() { 517 v8::TryCatch* try_catch_handler() {
512 return thread_local_top_.TryCatchHandler(); 518 return thread_local_top_.TryCatchHandler();
513 } 519 }
514 Address try_catch_handler_address() { 520 Address try_catch_handler_address() {
515 return thread_local_top_.try_catch_handler_address(); 521 return thread_local_top_.try_catch_handler_address();
516 } 522 }
517 bool* external_caught_exception_address() { 523 bool* external_caught_exception_address() {
518 return &thread_local_top_.external_caught_exception_; 524 return &thread_local_top_.external_caught_exception_;
519 } 525 }
526 bool in_exception_reporting() {
527 return thread_local_top_.in_exception_reporting_;
528 }
529 void set_in_exception_reporting(bool value) {
530 thread_local_top_.in_exception_reporting_ = value;
531 }
532 v8::TryCatch* catcher() {
533 return thread_local_top_.catcher_;
534 }
535 void set_catcher(v8::TryCatch* catcher) {
536 thread_local_top_.catcher_ = catcher;
537 }
520 538
521 MaybeObject** scheduled_exception_address() { 539 MaybeObject** scheduled_exception_address() {
522 return &thread_local_top_.scheduled_exception_; 540 return &thread_local_top_.scheduled_exception_;
523 } 541 }
524 MaybeObject* scheduled_exception() { 542 MaybeObject* scheduled_exception() {
525 ASSERT(has_scheduled_exception()); 543 ASSERT(has_scheduled_exception());
526 return thread_local_top_.scheduled_exception_; 544 return thread_local_top_.scheduled_exception_;
527 } 545 }
528 bool has_scheduled_exception() { 546 bool has_scheduled_exception() {
529 return !thread_local_top_.scheduled_exception_->IsTheHole(); 547 return !thread_local_top_.scheduled_exception_->IsTheHole();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 598
581 static int ArchiveSpacePerThread() { return sizeof(ThreadLocalTop); } 599 static int ArchiveSpacePerThread() { return sizeof(ThreadLocalTop); }
582 void FreeThreadResources() { thread_local_top_.Free(); } 600 void FreeThreadResources() { thread_local_top_.Free(); }
583 601
584 // This method is called by the api after operations that may throw 602 // This method is called by the api after operations that may throw
585 // exceptions. If an exception was thrown and not handled by an external 603 // exceptions. If an exception was thrown and not handled by an external
586 // handler the exception is scheduled to be rethrown when we return to running 604 // handler the exception is scheduled to be rethrown when we return to running
587 // JavaScript code. If an exception is scheduled true is returned. 605 // JavaScript code. If an exception is scheduled true is returned.
588 bool OptionalRescheduleException(bool is_bottom_call); 606 bool OptionalRescheduleException(bool is_bottom_call);
589 607
608 class ExceptionScope {
609 public:
610 explicit ExceptionScope(Isolate* isolate) :
611 // Scope currently can only be used for regular exceptions, not
612 // failures like OOM or termination exception.
613 isolate_(isolate),
614 pending_exception_(isolate_->pending_exception()->ToObjectUnchecked()),
615 catcher_(isolate_->catcher())
616 { }
617
618 ~ExceptionScope() {
619 isolate_->set_catcher(catcher_);
620 isolate_->set_pending_exception(*pending_exception_);
621 }
622
623 private:
624 Isolate* isolate_;
625 Handle<Object> pending_exception_;
626 v8::TryCatch* catcher_;
627 };
628
590 void SetCaptureStackTraceForUncaughtExceptions( 629 void SetCaptureStackTraceForUncaughtExceptions(
591 bool capture, 630 bool capture,
592 int frame_limit, 631 int frame_limit,
593 StackTrace::StackTraceOptions options); 632 StackTrace::StackTraceOptions options);
594 633
595 // Tells whether the current context has experienced an out of memory 634 // Tells whether the current context has experienced an out of memory
596 // exception. 635 // exception.
597 bool is_out_of_memory(); 636 bool is_out_of_memory();
598 637
599 void PrintCurrentStackTrace(FILE* out); 638 void PrintCurrentStackTrace(FILE* out);
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 void InitializeThreadLocal(); 1047 void InitializeThreadLocal();
1009 1048
1010 void PrintStackTrace(FILE* out, ThreadLocalTop* thread); 1049 void PrintStackTrace(FILE* out, ThreadLocalTop* thread);
1011 void MarkCompactPrologue(bool is_compacting, 1050 void MarkCompactPrologue(bool is_compacting,
1012 ThreadLocalTop* archived_thread_data); 1051 ThreadLocalTop* archived_thread_data);
1013 void MarkCompactEpilogue(bool is_compacting, 1052 void MarkCompactEpilogue(bool is_compacting,
1014 ThreadLocalTop* archived_thread_data); 1053 ThreadLocalTop* archived_thread_data);
1015 1054
1016 void FillCache(); 1055 void FillCache();
1017 1056
1057 void PropagatePendingExceptionToExternalTryCatch();
1058
1018 int stack_trace_nesting_level_; 1059 int stack_trace_nesting_level_;
1019 StringStream* incomplete_message_; 1060 StringStream* incomplete_message_;
1020 // The preallocated memory thread singleton. 1061 // The preallocated memory thread singleton.
1021 PreallocatedMemoryThread* preallocated_memory_thread_; 1062 PreallocatedMemoryThread* preallocated_memory_thread_;
1022 Address isolate_addresses_[k_isolate_address_count + 1]; // NOLINT 1063 Address isolate_addresses_[k_isolate_address_count + 1]; // NOLINT
1023 NoAllocationStringAllocator* preallocated_message_space_; 1064 NoAllocationStringAllocator* preallocated_message_space_;
1024 1065
1025 Bootstrapper* bootstrapper_; 1066 Bootstrapper* bootstrapper_;
1026 RuntimeProfiler* runtime_profiler_; 1067 RuntimeProfiler* runtime_profiler_;
1027 CompilationCache* compilation_cache_; 1068 CompilationCache* compilation_cache_;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 1336
1296 } } // namespace v8::internal 1337 } } // namespace v8::internal
1297 1338
1298 // TODO(isolates): Get rid of these -inl.h includes and place them only where 1339 // TODO(isolates): Get rid of these -inl.h includes and place them only where
1299 // they're needed. 1340 // they're needed.
1300 #include "allocation-inl.h" 1341 #include "allocation-inl.h"
1301 #include "zone-inl.h" 1342 #include "zone-inl.h"
1302 #include "frames-inl.h" 1343 #include "frames-inl.h"
1303 1344
1304 #endif // V8_ISOLATE_H_ 1345 #endif // V8_ISOLATE_H_
OLDNEW
« src/api.cc ('K') | « src/handles.cc ('k') | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698