Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 17 matching lines...) Expand all Loading... | |
| 28 // TODO(dcarney): remove | 28 // TODO(dcarney): remove |
| 29 #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT | 29 #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT |
| 30 | 30 |
| 31 #include "api.h" | 31 #include "api.h" |
| 32 | 32 |
| 33 #include <string.h> // For memcpy, strlen. | 33 #include <string.h> // For memcpy, strlen. |
| 34 #include <cmath> // For isnan. | 34 #include <cmath> // For isnan. |
| 35 #include "../include/v8-debug.h" | 35 #include "../include/v8-debug.h" |
| 36 #include "../include/v8-profiler.h" | 36 #include "../include/v8-profiler.h" |
| 37 #include "../include/v8-testing.h" | 37 #include "../include/v8-testing.h" |
| 38 #include "assert-scope.h" | |
| 38 #include "bootstrapper.h" | 39 #include "bootstrapper.h" |
| 39 #include "code-stubs.h" | 40 #include "code-stubs.h" |
| 40 #include "compiler.h" | 41 #include "compiler.h" |
| 41 #include "conversions-inl.h" | 42 #include "conversions-inl.h" |
| 42 #include "counters.h" | 43 #include "counters.h" |
| 43 #include "debug.h" | 44 #include "debug.h" |
| 44 #include "deoptimizer.h" | 45 #include "deoptimizer.h" |
| 45 #include "execution.h" | 46 #include "execution.h" |
| 46 #include "global-handles.h" | 47 #include "global-handles.h" |
| 47 #include "heap-profiler.h" | 48 #include "heap-profiler.h" |
| (...skipping 5051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5099 } | 5100 } |
| 5100 private: | 5101 private: |
| 5101 PersistentHandleVisitor* visitor_; | 5102 PersistentHandleVisitor* visitor_; |
| 5102 }; | 5103 }; |
| 5103 | 5104 |
| 5104 | 5105 |
| 5105 void v8::V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) { | 5106 void v8::V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) { |
| 5106 i::Isolate* isolate = i::Isolate::Current(); | 5107 i::Isolate* isolate = i::Isolate::Current(); |
| 5107 IsDeadCheck(isolate, "v8::V8::VisitHandlesWithClassId"); | 5108 IsDeadCheck(isolate, "v8::V8::VisitHandlesWithClassId"); |
| 5108 | 5109 |
| 5109 i::AssertNoAllocation no_allocation; | 5110 i::DisallowHeapAllocation no_allocation; |
| 5110 | 5111 |
| 5111 VisitorAdapter visitor_adapter(visitor); | 5112 VisitorAdapter visitor_adapter(visitor); |
| 5112 isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter); | 5113 isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter); |
| 5113 } | 5114 } |
| 5114 | 5115 |
| 5115 | 5116 |
| 5116 void v8::V8::VisitHandlesForPartialDependence( | 5117 void v8::V8::VisitHandlesForPartialDependence( |
| 5117 Isolate* exported_isolate, PersistentHandleVisitor* visitor) { | 5118 Isolate* exported_isolate, PersistentHandleVisitor* visitor) { |
| 5118 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate); | 5119 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate); |
| 5119 ASSERT(isolate == i::Isolate::Current()); | 5120 ASSERT(isolate == i::Isolate::Current()); |
| 5120 IsDeadCheck(isolate, "v8::V8::VisitHandlesForPartialDependence"); | 5121 IsDeadCheck(isolate, "v8::V8::VisitHandlesForPartialDependence"); |
| 5121 | 5122 |
| 5122 i::AssertNoAllocation no_allocation; | 5123 i::DisallowHeapAllocation no_allocation; |
| 5123 | 5124 |
| 5124 VisitorAdapter visitor_adapter(visitor); | 5125 VisitorAdapter visitor_adapter(visitor); |
| 5125 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds( | 5126 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds( |
| 5126 &visitor_adapter); | 5127 &visitor_adapter); |
| 5127 } | 5128 } |
| 5128 | 5129 |
| 5129 | 5130 |
| 5130 bool v8::V8::IdleNotification(int hint) { | 5131 bool v8::V8::IdleNotification(int hint) { |
| 5131 // Returning true tells the caller that it need not | 5132 // Returning true tells the caller that it need not |
| 5132 // continue to call IdleNotification. | 5133 // continue to call IdleNotification. |
| (...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6263 if (fits_into_int32_t) { | 6264 if (fits_into_int32_t) { |
| 6264 return Integer::New(static_cast<int32_t>(value), isolate); | 6265 return Integer::New(static_cast<int32_t>(value), isolate); |
| 6265 } | 6266 } |
| 6266 ENTER_V8(internal_isolate); | 6267 ENTER_V8(internal_isolate); |
| 6267 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 6268 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
| 6268 return Utils::IntegerToLocal(result); | 6269 return Utils::IntegerToLocal(result); |
| 6269 } | 6270 } |
| 6270 | 6271 |
| 6271 | 6272 |
| 6272 #ifdef DEBUG | 6273 #ifdef DEBUG |
| 6273 v8::AssertNoGCScope::AssertNoGCScope(v8::Isolate* isolate) | 6274 v8::AssertNoGCScope::AssertNoGCScope(v8::Isolate* isolate) |
|
Sven Panne
2013/06/03 09:58:23
This class is identical to DisallowHeapAllocation
Yang
2013/06/03 13:37:15
Done.
| |
| 6274 : isolate_(isolate), | 6275 : last_state_(i::AllowHeapAllocation::IsAllowed()) { |
| 6275 last_state_(i::EnterAllocationScope( | 6276 i::AllowHeapAllocation::SetIsAllowed(false); |
| 6276 reinterpret_cast<i::Isolate*>(isolate), false)) { | |
| 6277 } | 6277 } |
| 6278 | 6278 |
| 6279 v8::AssertNoGCScope::~AssertNoGCScope() { | 6279 v8::AssertNoGCScope::~AssertNoGCScope() { |
| 6280 i::ExitAllocationScope(reinterpret_cast<i::Isolate*>(isolate_), last_state_); | 6280 i::AllowHeapAllocation::SetIsAllowed(last_state_); |
| 6281 } | 6281 } |
| 6282 #endif | 6282 #endif |
| 6283 | 6283 |
| 6284 | 6284 |
| 6285 void V8::IgnoreOutOfMemoryException() { | 6285 void V8::IgnoreOutOfMemoryException() { |
| 6286 EnterIsolateIfNeeded()->set_ignore_out_of_memory(true); | 6286 EnterIsolateIfNeeded()->set_ignore_out_of_memory(true); |
| 6287 } | 6287 } |
| 6288 | 6288 |
| 6289 | 6289 |
| 6290 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { | 6290 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { |
| (...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7802 } | 7802 } |
| 7803 | 7803 |
| 7804 | 7804 |
| 7805 DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) { | 7805 DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) { |
| 7806 DeferredHandles* deferred = | 7806 DeferredHandles* deferred = |
| 7807 new DeferredHandles(isolate()->handle_scope_data()->next, isolate()); | 7807 new DeferredHandles(isolate()->handle_scope_data()->next, isolate()); |
| 7808 | 7808 |
| 7809 while (!blocks_.is_empty()) { | 7809 while (!blocks_.is_empty()) { |
| 7810 Object** block_start = blocks_.last(); | 7810 Object** block_start = blocks_.last(); |
| 7811 Object** block_limit = &block_start[kHandleBlockSize]; | 7811 Object** block_limit = &block_start[kHandleBlockSize]; |
| 7812 // We should not need to check for NoHandleAllocation here. Assert | 7812 // We should not need to check for RequireNewHandleScope here. Assert this. |
| 7813 // this. | |
| 7814 ASSERT(prev_limit == block_limit || | 7813 ASSERT(prev_limit == block_limit || |
| 7815 !(block_start <= prev_limit && prev_limit <= block_limit)); | 7814 !(block_start <= prev_limit && prev_limit <= block_limit)); |
| 7816 if (prev_limit == block_limit) break; | 7815 if (prev_limit == block_limit) break; |
| 7817 deferred->blocks_.Add(blocks_.last()); | 7816 deferred->blocks_.Add(blocks_.last()); |
| 7818 blocks_.RemoveLast(); | 7817 blocks_.RemoveLast(); |
| 7819 } | 7818 } |
| 7820 | 7819 |
| 7821 // deferred->blocks_ now contains the blocks installed on the | 7820 // deferred->blocks_ now contains the blocks installed on the |
| 7822 // HandleScope stack since BeginDeferredScope was called, but in | 7821 // HandleScope stack since BeginDeferredScope was called, but in |
| 7823 // reverse order. | 7822 // reverse order. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7857 | 7856 |
| 7858 v->VisitPointers(blocks_.first(), first_block_limit_); | 7857 v->VisitPointers(blocks_.first(), first_block_limit_); |
| 7859 | 7858 |
| 7860 for (int i = 1; i < blocks_.length(); i++) { | 7859 for (int i = 1; i < blocks_.length(); i++) { |
| 7861 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 7860 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
| 7862 } | 7861 } |
| 7863 } | 7862 } |
| 7864 | 7863 |
| 7865 | 7864 |
| 7866 } } // namespace v8::internal | 7865 } } // namespace v8::internal |
| OLD | NEW |