| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 thread_local.IncrementCallDepth(); \ | 64 thread_local.IncrementCallDepth(); \ |
| 65 ASSERT(!i::Top::external_caught_exception()); \ | 65 ASSERT(!i::Top::external_caught_exception()); \ |
| 66 bool has_pending_exception = false | 66 bool has_pending_exception = false |
| 67 | 67 |
| 68 | 68 |
| 69 #define EXCEPTION_BAILOUT_CHECK(value) \ | 69 #define EXCEPTION_BAILOUT_CHECK(value) \ |
| 70 do { \ | 70 do { \ |
| 71 thread_local.DecrementCallDepth(); \ | 71 thread_local.DecrementCallDepth(); \ |
| 72 if (has_pending_exception) { \ | 72 if (has_pending_exception) { \ |
| 73 if (thread_local.CallDepthIsZero() && i::Top::is_out_of_memory()) { \ | 73 if (thread_local.CallDepthIsZero() && i::Top::is_out_of_memory()) { \ |
| 74 if (!thread_local.IgnoreOutOfMemory()) \ | 74 if (!thread_local.ignore_out_of_memory()) \ |
| 75 i::V8::FatalProcessOutOfMemory(NULL); \ | 75 i::V8::FatalProcessOutOfMemory(NULL); \ |
| 76 } \ | 76 } \ |
| 77 bool call_depth_is_zero = thread_local.CallDepthIsZero(); \ | 77 bool call_depth_is_zero = thread_local.CallDepthIsZero(); \ |
| 78 i::Top::OptionalRescheduleException(call_depth_is_zero); \ | 78 i::Top::OptionalRescheduleException(call_depth_is_zero); \ |
| 79 return value; \ | 79 return value; \ |
| 80 } \ | 80 } \ |
| 81 } while (false) | 81 } while (false) |
| 82 | 82 |
| 83 | 83 |
| 84 #define API_ENTRY_CHECK(msg) \ | 84 #define API_ENTRY_CHECK(msg) \ |
| (...skipping 3095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3180 if (i::Smi::IsValid(value)) { | 3180 if (i::Smi::IsValid(value)) { |
| 3181 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value))); | 3181 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value))); |
| 3182 } | 3182 } |
| 3183 ENTER_V8; | 3183 ENTER_V8; |
| 3184 i::Handle<i::Object> result = i::Factory::NewNumber(value); | 3184 i::Handle<i::Object> result = i::Factory::NewNumber(value); |
| 3185 return Utils::IntegerToLocal(result); | 3185 return Utils::IntegerToLocal(result); |
| 3186 } | 3186 } |
| 3187 | 3187 |
| 3188 | 3188 |
| 3189 void V8::IgnoreOutOfMemoryException() { | 3189 void V8::IgnoreOutOfMemoryException() { |
| 3190 thread_local.SetIgnoreOutOfMemory(true); | 3190 thread_local.set_ignore_out_of_memory(true); |
| 3191 } | 3191 } |
| 3192 | 3192 |
| 3193 | 3193 |
| 3194 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { | 3194 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { |
| 3195 EnsureInitialized("v8::V8::AddMessageListener()"); | 3195 EnsureInitialized("v8::V8::AddMessageListener()"); |
| 3196 ON_BAILOUT("v8::V8::AddMessageListener()", return false); | 3196 ON_BAILOUT("v8::V8::AddMessageListener()", return false); |
| 3197 ENTER_V8; | 3197 ENTER_V8; |
| 3198 HandleScope scope; | 3198 HandleScope scope; |
| 3199 NeanderArray listeners(i::Factory::message_listeners()); | 3199 NeanderArray listeners(i::Factory::message_listeners()); |
| 3200 NeanderObject obj(2); | 3200 NeanderObject obj(2); |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3662 #endif // ENABLE_DEBUGGER_SUPPORT | 3662 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3663 | 3663 |
| 3664 namespace internal { | 3664 namespace internal { |
| 3665 | 3665 |
| 3666 | 3666 |
| 3667 HandleScopeImplementer* HandleScopeImplementer::instance() { | 3667 HandleScopeImplementer* HandleScopeImplementer::instance() { |
| 3668 return &thread_local; | 3668 return &thread_local; |
| 3669 } | 3669 } |
| 3670 | 3670 |
| 3671 | 3671 |
| 3672 void HandleScopeImplementer::FreeThreadResources() { |
| 3673 thread_local.Free(); |
| 3674 } |
| 3675 |
| 3676 |
| 3672 char* HandleScopeImplementer::ArchiveThread(char* storage) { | 3677 char* HandleScopeImplementer::ArchiveThread(char* storage) { |
| 3673 return thread_local.ArchiveThreadHelper(storage); | 3678 return thread_local.ArchiveThreadHelper(storage); |
| 3674 } | 3679 } |
| 3675 | 3680 |
| 3676 | 3681 |
| 3677 char* HandleScopeImplementer::ArchiveThreadHelper(char* storage) { | 3682 char* HandleScopeImplementer::ArchiveThreadHelper(char* storage) { |
| 3678 v8::ImplementationUtilities::HandleScopeData* current = | 3683 v8::ImplementationUtilities::HandleScopeData* current = |
| 3679 v8::ImplementationUtilities::CurrentHandleScope(); | 3684 v8::ImplementationUtilities::CurrentHandleScope(); |
| 3680 handle_scope_data_ = *current; | 3685 handle_scope_data_ = *current; |
| 3681 memcpy(storage, this, sizeof(*this)); | 3686 memcpy(storage, this, sizeof(*this)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3699 | 3704 |
| 3700 char* HandleScopeImplementer::RestoreThreadHelper(char* storage) { | 3705 char* HandleScopeImplementer::RestoreThreadHelper(char* storage) { |
| 3701 memcpy(this, storage, sizeof(*this)); | 3706 memcpy(this, storage, sizeof(*this)); |
| 3702 *v8::ImplementationUtilities::CurrentHandleScope() = handle_scope_data_; | 3707 *v8::ImplementationUtilities::CurrentHandleScope() = handle_scope_data_; |
| 3703 return storage + ArchiveSpacePerThread(); | 3708 return storage + ArchiveSpacePerThread(); |
| 3704 } | 3709 } |
| 3705 | 3710 |
| 3706 | 3711 |
| 3707 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) { | 3712 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) { |
| 3708 // Iterate over all handles in the blocks except for the last. | 3713 // Iterate over all handles in the blocks except for the last. |
| 3709 for (int i = Blocks()->length() - 2; i >= 0; --i) { | 3714 for (int i = blocks()->length() - 2; i >= 0; --i) { |
| 3710 Object** block = Blocks()->at(i); | 3715 Object** block = blocks()->at(i); |
| 3711 v->VisitPointers(block, &block[kHandleBlockSize]); | 3716 v->VisitPointers(block, &block[kHandleBlockSize]); |
| 3712 } | 3717 } |
| 3713 | 3718 |
| 3714 // Iterate over live handles in the last block (if any). | 3719 // Iterate over live handles in the last block (if any). |
| 3715 if (!Blocks()->is_empty()) { | 3720 if (!blocks()->is_empty()) { |
| 3716 v->VisitPointers(Blocks()->last(), handle_scope_data_.next); | 3721 v->VisitPointers(blocks()->last(), handle_scope_data_.next); |
| 3717 } | 3722 } |
| 3718 | 3723 |
| 3719 if (!saved_contexts_.is_empty()) { | 3724 if (!saved_contexts_.is_empty()) { |
| 3720 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first()); | 3725 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first()); |
| 3721 v->VisitPointers(start, start + saved_contexts_.length()); | 3726 v->VisitPointers(start, start + saved_contexts_.length()); |
| 3722 } | 3727 } |
| 3723 } | 3728 } |
| 3724 | 3729 |
| 3725 | 3730 |
| 3726 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { | 3731 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { |
| 3727 v8::ImplementationUtilities::HandleScopeData* current = | 3732 v8::ImplementationUtilities::HandleScopeData* current = |
| 3728 v8::ImplementationUtilities::CurrentHandleScope(); | 3733 v8::ImplementationUtilities::CurrentHandleScope(); |
| 3729 thread_local.handle_scope_data_ = *current; | 3734 thread_local.handle_scope_data_ = *current; |
| 3730 thread_local.IterateThis(v); | 3735 thread_local.IterateThis(v); |
| 3731 } | 3736 } |
| 3732 | 3737 |
| 3733 | 3738 |
| 3734 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 3739 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 3735 HandleScopeImplementer* thread_local = | 3740 HandleScopeImplementer* thread_local = |
| 3736 reinterpret_cast<HandleScopeImplementer*>(storage); | 3741 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 3737 thread_local->IterateThis(v); | 3742 thread_local->IterateThis(v); |
| 3738 return storage + ArchiveSpacePerThread(); | 3743 return storage + ArchiveSpacePerThread(); |
| 3739 } | 3744 } |
| 3740 | 3745 |
| 3741 } } // namespace v8::internal | 3746 } } // namespace v8::internal |
| OLD | NEW |