Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: runtime/bin/common.cc

Issue 15772005: - Add different types for persistent and weak persistent handles (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/io_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "bin/isolate_data.h" 6 #include "bin/isolate_data.h"
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 namespace dart { 9 namespace dart {
10 namespace bin { 10 namespace bin {
11 11
12 void FUNCTION_NAME(Common_IsBuiltinList)(Dart_NativeArguments args) { 12 void FUNCTION_NAME(Common_IsBuiltinList)(Dart_NativeArguments args) {
13 Dart_EnterScope(); 13 Dart_EnterScope();
14 Dart_Handle list = Dart_GetNativeArgument(args, 0); 14 Dart_Handle list = Dart_GetNativeArgument(args, 0);
15 Dart_Handle list_class = Dart_InstanceGetClass(list); 15 Dart_Handle list_class = Dart_InstanceGetClass(list);
16 ASSERT(!Dart_IsError(list_class)); 16 ASSERT(!Dart_IsError(list_class));
17 17
18 // Fetch the cached builtin array types for this isolate. 18 // Fetch the cached builtin array types for this isolate.
19 IsolateData* isolate_data = 19 IsolateData* isolate_data =
20 reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData()); 20 reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData());
21 Dart_Handle object_array_class = isolate_data->object_array_class;
22 Dart_Handle growable_object_array_class =
23 isolate_data->growable_object_array_class;
24 Dart_Handle immutable_array_class = isolate_data->immutable_array_class;
25 21
26 // If we have not cached the class pointers in the isolate data, 22 // If we have not cached the class pointers in the isolate data,
27 // look them up and cache them now. 23 // look them up and cache them now.
28 if (object_array_class == NULL) { 24 if (isolate_data->object_array_class == NULL) {
29 Dart_Handle core_lib = 25 Dart_Handle core_lib =
30 Dart_LookupLibrary(Dart_NewStringFromCString("dart:core")); 26 Dart_LookupLibrary(Dart_NewStringFromCString("dart:core"));
31 ASSERT(!Dart_IsError(core_lib)); 27 ASSERT(!Dart_IsError(core_lib));
32 object_array_class = 28
29 Dart_Handle cls =
33 Dart_GetClass(core_lib, Dart_NewStringFromCString("_ObjectArray")); 30 Dart_GetClass(core_lib, Dart_NewStringFromCString("_ObjectArray"));
34 ASSERT(!Dart_IsError(object_array_class)); 31 ASSERT(!Dart_IsError(cls));
35 immutable_array_class = 32 isolate_data->object_array_class = Dart_NewPersistentHandle(cls);
36 Dart_GetClass(core_lib, Dart_NewStringFromCString("_ImmutableArray")); 33 ASSERT(isolate_data->object_array_class != NULL);
37 ASSERT(!Dart_IsError(immutable_array_class)); 34
38 growable_object_array_class = Dart_GetClass( 35 cls = Dart_GetClass(core_lib, Dart_NewStringFromCString("_ImmutableArray"));
36 ASSERT(!Dart_IsError(cls));
37 isolate_data->immutable_array_class = Dart_NewPersistentHandle(cls);
38 ASSERT(isolate_data->immutable_array_class != NULL);
39
40 cls = Dart_GetClass(
39 core_lib, Dart_NewStringFromCString("_GrowableObjectArray")); 41 core_lib, Dart_NewStringFromCString("_GrowableObjectArray"));
40 ASSERT(!Dart_IsError(growable_object_array_class)); 42 ASSERT(!Dart_IsError(cls));
41 // Update the cache. 43 isolate_data->growable_object_array_class = Dart_NewPersistentHandle(cls);
42 isolate_data->object_array_class = 44 ASSERT(isolate_data->growable_object_array_class != NULL);
43 Dart_NewPersistentHandle(object_array_class);
44 ASSERT(!Dart_IsError(isolate_data->object_array_class));
45 isolate_data->growable_object_array_class =
46 Dart_NewPersistentHandle(growable_object_array_class);
47 ASSERT(!Dart_IsError(isolate_data->growable_object_array_class));
48 isolate_data->immutable_array_class =
49 Dart_NewPersistentHandle(immutable_array_class);
50 ASSERT(!Dart_IsError(isolate_data->immutable_array_class));
51 } 45 }
52 46
47 Dart_Handle object_array_class =
48 Dart_HandleFromPersistent(isolate_data->object_array_class);
49 Dart_Handle growable_object_array_class =
50 Dart_HandleFromPersistent(isolate_data->growable_object_array_class);
51 Dart_Handle immutable_array_class =
52 Dart_HandleFromPersistent(isolate_data->immutable_array_class);
53 bool builtin_array = 53 bool builtin_array =
54 (Dart_IdentityEquals(list_class, growable_object_array_class) || 54 (Dart_IdentityEquals(list_class, growable_object_array_class) ||
55 Dart_IdentityEquals(list_class, object_array_class) || 55 Dart_IdentityEquals(list_class, object_array_class) ||
56 Dart_IdentityEquals(list_class, immutable_array_class)); 56 Dart_IdentityEquals(list_class, immutable_array_class));
57 Dart_SetReturnValue(args, Dart_NewBoolean(builtin_array)); 57 Dart_SetReturnValue(args, Dart_NewBoolean(builtin_array));
58 Dart_ExitScope(); 58 Dart_ExitScope();
59 } 59 }
60 60
61 } // namespace bin 61 } // namespace bin
62 } // namespace dart 62 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/io_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698