| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 } | 217 } |
| 218 | 218 |
| 219 | 219 |
| 220 uword Api::Allocate(intptr_t size) { | 220 uword Api::Allocate(intptr_t size) { |
| 221 Isolate* isolate = Isolate::Current(); | 221 Isolate* isolate = Isolate::Current(); |
| 222 ASSERT(isolate != NULL); | 222 ASSERT(isolate != NULL); |
| 223 ApiState* state = isolate->api_state(); | 223 ApiState* state = isolate->api_state(); |
| 224 ASSERT(state != NULL); | 224 ASSERT(state != NULL); |
| 225 ApiLocalScope* scope = state->top_scope(); | 225 ApiLocalScope* scope = state->top_scope(); |
| 226 ASSERT(scope != NULL); | 226 ASSERT(scope != NULL); |
| 227 return scope->zone().Allocate(size); | 227 return scope->zone()->Allocate(size); |
| 228 } | 228 } |
| 229 | 229 |
| 230 | 230 |
| 231 uword Api::Reallocate(uword ptr, intptr_t old_size, intptr_t new_size) { | 231 uword Api::Reallocate(uword ptr, intptr_t old_size, intptr_t new_size) { |
| 232 Isolate* isolate = Isolate::Current(); | 232 Isolate* isolate = Isolate::Current(); |
| 233 ASSERT(isolate != NULL); | 233 ASSERT(isolate != NULL); |
| 234 ApiState* state = isolate->api_state(); | 234 ApiState* state = isolate->api_state(); |
| 235 ASSERT(state != NULL); | 235 ASSERT(state != NULL); |
| 236 ApiLocalScope* scope = state->top_scope(); | 236 ApiLocalScope* scope = state->top_scope(); |
| 237 ASSERT(scope != NULL); | 237 ASSERT(scope != NULL); |
| 238 return scope->zone().Reallocate(ptr, old_size, new_size); | 238 return scope->zone()->Reallocate(ptr, old_size, new_size); |
| 239 } | 239 } |
| 240 | 240 |
| 241 | 241 |
| 242 void Api::InitOnce() { | 242 void Api::InitOnce() { |
| 243 ASSERT(api_native_key_ == Thread::kUnsetThreadLocalKey); | 243 ASSERT(api_native_key_ == Thread::kUnsetThreadLocalKey); |
| 244 api_native_key_ = Thread::CreateThreadLocal(); | 244 api_native_key_ = Thread::CreateThreadLocal(); |
| 245 ASSERT(api_native_key_ != Thread::kUnsetThreadLocalKey); | 245 ASSERT(api_native_key_ != Thread::kUnsetThreadLocalKey); |
| 246 } | 246 } |
| 247 | 247 |
| 248 | 248 |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 Isolate* isolate = Isolate::Current(); | 829 Isolate* isolate = Isolate::Current(); |
| 830 CHECK_ISOLATE_SCOPE(isolate); | 830 CHECK_ISOLATE_SCOPE(isolate); |
| 831 ApiState* state = isolate->api_state(); | 831 ApiState* state = isolate->api_state(); |
| 832 ApiLocalScope* scope = state->top_scope(); | 832 ApiLocalScope* scope = state->top_scope(); |
| 833 | 833 |
| 834 state->set_top_scope(scope->previous()); // Reset top scope to previous. | 834 state->set_top_scope(scope->previous()); // Reset top scope to previous. |
| 835 delete scope; // Free up the old scope which we have just exited. | 835 delete scope; // Free up the old scope which we have just exited. |
| 836 } | 836 } |
| 837 | 837 |
| 838 | 838 |
| 839 DART_EXPORT uint8_t* Dart_ScopeAllocate(intptr_t size) { |
| 840 ApiZone* zone; |
| 841 Isolate* isolate = Isolate::Current(); |
| 842 if (isolate != NULL) { |
| 843 ApiState* state = isolate->api_state(); |
| 844 if (state == NULL) return NULL; |
| 845 ApiLocalScope* scope = state->top_scope(); |
| 846 zone = scope->zone(); |
| 847 } else { |
| 848 ApiNativeScope* scope = ApiNativeScope::Current(); |
| 849 if (scope == NULL) return NULL; |
| 850 zone = scope->zone(); |
| 851 } |
| 852 return reinterpret_cast<uint8_t*>(zone->Allocate(size)); |
| 853 } |
| 854 |
| 855 |
| 839 // --- Objects ---- | 856 // --- Objects ---- |
| 840 | 857 |
| 841 | 858 |
| 842 DART_EXPORT Dart_Handle Dart_Null() { | 859 DART_EXPORT Dart_Handle Dart_Null() { |
| 843 CHECK_ISOLATE_SCOPE(Isolate::Current()); | 860 CHECK_ISOLATE_SCOPE(Isolate::Current()); |
| 844 return Api::Null(); | 861 return Api::Null(); |
| 845 } | 862 } |
| 846 | 863 |
| 847 | 864 |
| 848 DART_EXPORT bool Dart_IsNull(Dart_Handle object) { | 865 DART_EXPORT bool Dart_IsNull(Dart_Handle object) { |
| (...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2688 *buffer = NULL; | 2705 *buffer = NULL; |
| 2689 } | 2706 } |
| 2690 delete debug_region; | 2707 delete debug_region; |
| 2691 } else { | 2708 } else { |
| 2692 *buffer = NULL; | 2709 *buffer = NULL; |
| 2693 *buffer_size = 0; | 2710 *buffer_size = 0; |
| 2694 } | 2711 } |
| 2695 } | 2712 } |
| 2696 | 2713 |
| 2697 } // namespace dart | 2714 } // namespace dart |
| OLD | NEW |