| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/native_entry.h" | 5 #include "vm/native_entry.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 void NativeEntry::NativeCallWrapper(Dart_NativeArguments args, | 46 void NativeEntry::NativeCallWrapper(Dart_NativeArguments args, |
| 47 Dart_NativeFunction func) { | 47 Dart_NativeFunction func) { |
| 48 CHECK_STACK_ALIGNMENT; | 48 CHECK_STACK_ALIGNMENT; |
| 49 VERIFY_ON_TRANSITION; | 49 VERIFY_ON_TRANSITION; |
| 50 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 50 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
| 51 Isolate* isolate = arguments->isolate(); | 51 Isolate* isolate = arguments->isolate(); |
| 52 ApiState* state = isolate->api_state(); | 52 ApiState* state = isolate->api_state(); |
| 53 ASSERT(state != NULL); | 53 ASSERT(state != NULL); |
| 54 ApiLocalScope* current_top_scope = state->top_scope(); | 54 ApiLocalScope* current_top_scope = state->top_scope(); |
| 55 ApiLocalScope* scope = state->reusable_scope(); | 55 ApiLocalScope* scope = state->reusable_scope(); |
| 56 TRACE_NATIVES("0x%" Px "", reinterpret_cast<uintptr_t>(func)); |
| 56 if (scope == NULL) { | 57 if (scope == NULL) { |
| 57 scope = new ApiLocalScope(current_top_scope, | 58 scope = new ApiLocalScope(current_top_scope, |
| 58 isolate->top_exit_frame_info()); | 59 isolate->top_exit_frame_info()); |
| 59 ASSERT(scope != NULL); | 60 ASSERT(scope != NULL); |
| 60 } else { | 61 } else { |
| 61 scope->Reinit(isolate, | 62 scope->Reinit(isolate, |
| 62 current_top_scope, | 63 current_top_scope, |
| 63 isolate->top_exit_frame_info()); | 64 isolate->top_exit_frame_info()); |
| 64 state->set_reusable_scope(NULL); | 65 state->set_reusable_scope(NULL); |
| 65 } | 66 } |
| 66 state->set_top_scope(scope); // New scope is now the top scope. | 67 state->set_top_scope(scope); // New scope is now the top scope. |
| 67 | 68 |
| 68 func(args); | 69 func(args); |
| 69 | 70 |
| 70 ASSERT(current_top_scope == scope->previous()); | 71 ASSERT(current_top_scope == scope->previous()); |
| 71 state->set_top_scope(current_top_scope); // Reset top scope to previous. | 72 state->set_top_scope(current_top_scope); // Reset top scope to previous. |
| 72 if (state->reusable_scope() == NULL) { | 73 if (state->reusable_scope() == NULL) { |
| 73 scope->Reset(isolate); // Reset the old scope which we just exited. | 74 scope->Reset(isolate); // Reset the old scope which we just exited. |
| 74 state->set_reusable_scope(scope); | 75 state->set_reusable_scope(scope); |
| 75 } else { | 76 } else { |
| 76 ASSERT(state->reusable_scope() != scope); | 77 ASSERT(state->reusable_scope() != scope); |
| 77 delete scope; | 78 delete scope; |
| 78 } | 79 } |
| 79 DEOPTIMIZE_ALOT; | 80 DEOPTIMIZE_ALOT; |
| 80 VERIFY_ON_TRANSITION; | 81 VERIFY_ON_TRANSITION; |
| 81 } | 82 } |
| 82 | 83 |
| 83 } // namespace dart | 84 } // namespace dart |
| OLD | NEW |