Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 #include "vm/bootstrap_natives.h" | |
| 6 | |
| 7 #include "include/dart_api.h" | |
| 8 | |
| 9 #include "vm/bigint_operations.h" | |
| 10 #include "vm/exceptions.h" | |
| 11 #include "vm/native_entry.h" | |
| 12 #include "vm/object.h" | |
| 13 #include "vm/object_store.h" | |
| 14 | |
| 15 namespace dart { | |
| 16 | |
| 17 // dart:profiler. | |
| 18 | |
| 19 DEFINE_NATIVE_ENTRY(UserTag_new, 2) { | |
| 20 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); | |
| 21 GET_NON_NULL_NATIVE_ARGUMENT(String, tag_label, arguments->NativeArgAt(1)); | |
| 22 if (UserTag::TagTableIsFull(isolate)) { | |
| 23 const String& error = String::Handle( | |
| 24 String::NewFormatted("UserTag instance limit (%" Pd ") reached.", | |
| 25 UserTags::kMaxUserTags)); | |
| 26 const Array& args = Array::Handle(Array::New(1)); | |
| 27 args.SetAt(0, error); | |
| 28 Exceptions::ThrowByType(Exceptions::kUnsupported, args); | |
| 29 } | |
| 30 return UserTag::New(tag_label); | |
| 31 } | |
| 32 | |
| 33 | |
| 34 DEFINE_NATIVE_ENTRY(UserTag_label, 1) { | |
| 35 const UserTag& self = UserTag::CheckedHandle(arguments->NativeArgAt(0)); | |
| 36 return self.label(); | |
| 37 } | |
| 38 | |
| 39 | |
| 40 DEFINE_NATIVE_ENTRY(UserTag_makeCurrent, 1) { | |
| 41 const UserTag& self = UserTag::CheckedHandle(arguments->NativeArgAt(0)); | |
| 42 self.MakeActive(); | |
| 43 return Object::null(); | |
| 44 } | |
| 45 | |
| 46 | |
| 47 DEFINE_NATIVE_ENTRY(Profiler_getCurrentTag, 0) { | |
| 48 ObjectStore* object_store = isolate->object_store(); | |
| 49 return object_store->current_tag(); | |
|
siva
2014/04/09 21:32:01
Not sure why the current tag is in the object stor
| |
| 50 } | |
| 51 | |
| 52 | |
| 53 DEFINE_NATIVE_ENTRY(Profiler_clearCurrentTag, 0) { | |
| 54 ObjectStore* object_store = isolate->object_store(); | |
| 55 // Use a NoGCScope to avoid creating a handle for the old current. | |
| 56 NoGCScope no_gc; | |
| 57 RawUserTag* old_current = object_store->current_tag(); | |
| 58 UserTag::ClearActive(); | |
| 59 return old_current; | |
| 60 } | |
| 61 | |
| 62 } // namespace dart | |
| OLD | NEW |