Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 } | 486 } |
| 487 | 487 |
| 488 | 488 |
| 489 void Api::InitOnce() { | 489 void Api::InitOnce() { |
| 490 ASSERT(api_native_key_ == OSThread::kUnsetThreadLocalKey); | 490 ASSERT(api_native_key_ == OSThread::kUnsetThreadLocalKey); |
| 491 api_native_key_ = OSThread::CreateThreadLocal(); | 491 api_native_key_ = OSThread::CreateThreadLocal(); |
| 492 ASSERT(api_native_key_ != OSThread::kUnsetThreadLocalKey); | 492 ASSERT(api_native_key_ != OSThread::kUnsetThreadLocalKey); |
| 493 } | 493 } |
| 494 | 494 |
| 495 | 495 |
| 496 static Dart_Handle InitNewReadOnlyApiHandle(RawObject* raw) { | |
| 497 ASSERT(raw->IsVMHeapObject()); | |
| 498 LocalHandle* ref = Dart::AllocateReadOnlyApiHandle(); | |
| 499 ref->set_raw(raw); | |
| 500 return reinterpret_cast<Dart_Handle>(ref); | |
|
Ivan Posva
2015/06/17 16:58:57
Not sure how often we need to make LocalHandles in
| |
| 501 } | |
| 502 | |
| 503 | |
| 496 void Api::InitHandles() { | 504 void Api::InitHandles() { |
| 497 Isolate* isolate = Isolate::Current(); | 505 Isolate* isolate = Isolate::Current(); |
| 498 ASSERT(isolate != NULL); | 506 ASSERT(isolate != NULL); |
| 499 ASSERT(isolate == Dart::vm_isolate()); | 507 ASSERT(isolate == Dart::vm_isolate()); |
| 500 ApiState* state = isolate->api_state(); | 508 ApiState* state = isolate->api_state(); |
| 501 ASSERT(state != NULL); | 509 ASSERT(state != NULL); |
| 510 | |
| 502 ASSERT(true_handle_ == NULL); | 511 ASSERT(true_handle_ == NULL); |
| 503 true_handle_ = Api::InitNewHandle(isolate, Bool::True().raw()); | 512 true_handle_ = InitNewReadOnlyApiHandle(Bool::True().raw()); |
| 504 | 513 |
| 505 ASSERT(false_handle_ == NULL); | 514 ASSERT(false_handle_ == NULL); |
| 506 false_handle_ = Api::InitNewHandle(isolate, Bool::False().raw()); | 515 false_handle_ = InitNewReadOnlyApiHandle(Bool::False().raw()); |
| 507 | 516 |
| 508 ASSERT(null_handle_ == NULL); | 517 ASSERT(null_handle_ == NULL); |
| 509 null_handle_ = Api::InitNewHandle(isolate, Object::null()); | 518 null_handle_ = InitNewReadOnlyApiHandle(Object::null()); |
| 510 | 519 |
| 511 ASSERT(empty_string_handle_ == NULL); | 520 ASSERT(empty_string_handle_ == NULL); |
| 512 empty_string_handle_ = Api::InitNewHandle(isolate, Symbols::Empty().raw()); | 521 empty_string_handle_ = InitNewReadOnlyApiHandle(Symbols::Empty().raw()); |
| 513 } | 522 } |
| 514 | 523 |
| 515 | 524 |
| 516 bool Api::StringGetPeerHelper(NativeArguments* arguments, | 525 bool Api::StringGetPeerHelper(NativeArguments* arguments, |
| 517 int arg_index, | 526 int arg_index, |
| 518 void** peer) { | 527 void** peer) { |
| 519 NoSafepointScope no_safepoint_scope; | 528 NoSafepointScope no_safepoint_scope; |
| 520 RawObject* raw_obj = arguments->NativeArgAt(arg_index); | 529 RawObject* raw_obj = arguments->NativeArgAt(arg_index); |
| 521 if (!raw_obj->IsHeapObject()) { | 530 if (!raw_obj->IsHeapObject()) { |
| 522 return false; | 531 return false; |
| (...skipping 5249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5772 ASSERT(stream != NULL); | 5781 ASSERT(stream != NULL); |
| 5773 TimelineEvent* event = stream->StartEvent(); | 5782 TimelineEvent* event = stream->StartEvent(); |
| 5774 if (event != NULL) { | 5783 if (event != NULL) { |
| 5775 event->AsyncEnd(label, async_id); | 5784 event->AsyncEnd(label, async_id); |
| 5776 event->Complete(); | 5785 event->Complete(); |
| 5777 } | 5786 } |
| 5778 return Api::Success(); | 5787 return Api::Success(); |
| 5779 } | 5788 } |
| 5780 | 5789 |
| 5781 } // namespace dart | 5790 } // namespace dart |
| OLD | NEW |