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

Side by Side Diff: vm/object.cc

Issue 10827209: Unify class ids and snapshot object ids list so that we don't have disparate and sometimes confusin… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 4 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 | « vm/object.h ('k') | vm/object_store.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 "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 "instead of showing the corresponding interface names (e.g. \"String\")"); 42 "instead of showing the corresponding interface names (e.g. \"String\")");
43 DECLARE_FLAG(bool, trace_compiler); 43 DECLARE_FLAG(bool, trace_compiler);
44 DECLARE_FLAG(bool, enable_type_checks); 44 DECLARE_FLAG(bool, enable_type_checks);
45 45
46 static const char* kGetterPrefix = "get:"; 46 static const char* kGetterPrefix = "get:";
47 static const intptr_t kGetterPrefixLength = strlen(kGetterPrefix); 47 static const intptr_t kGetterPrefixLength = strlen(kGetterPrefix);
48 static const char* kSetterPrefix = "set:"; 48 static const char* kSetterPrefix = "set:";
49 static const intptr_t kSetterPrefixLength = strlen(kSetterPrefix); 49 static const intptr_t kSetterPrefixLength = strlen(kSetterPrefix);
50 50
51 cpp_vtable Object::handle_vtable_ = 0; 51 cpp_vtable Object::handle_vtable_ = 0;
52 cpp_vtable Object::builtin_vtables_[kNumPredefinedKinds] = { 0 }; 52 cpp_vtable Object::builtin_vtables_[kNumPredefinedCids] = { 0 };
53 cpp_vtable Smi::handle_vtable_ = 0; 53 cpp_vtable Smi::handle_vtable_ = 0;
54 54
55 // These are initialized to a value that will force a illegal memory access if 55 // These are initialized to a value that will force a illegal memory access if
56 // they are being used. 56 // they are being used.
57 #if defined(RAW_NULL) 57 #if defined(RAW_NULL)
58 #error RAW_NULL should not be defined. 58 #error RAW_NULL should not be defined.
59 #endif 59 #endif
60 #define RAW_NULL kHeapObjectTag 60 #define RAW_NULL kHeapObjectTag
61 RawObject* Object::null_ = reinterpret_cast<RawInstance*>(RAW_NULL); 61 RawObject* Object::null_ = reinterpret_cast<RawInstance*>(RAW_NULL);
62 RawInstance* Object::sentinel_ = reinterpret_cast<RawInstance*>(RAW_NULL); 62 RawInstance* Object::sentinel_ = reinterpret_cast<RawInstance*>(RAW_NULL);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 if (is_setter) { 178 if (is_setter) {
179 // Setters need to end with '='. 179 // Setters need to end with '='.
180 const String& suffix = String::Handle(Symbols::Equals()); 180 const String& suffix = String::Handle(Symbols::Equals());
181 return String::Concat(result, suffix); 181 return String::Concat(result, suffix);
182 } 182 }
183 183
184 return result.raw(); 184 return result.raw();
185 } 185 }
186 186
187 187
188 int Object::GetSingletonClassIndex(const RawClass* raw_class) { 188 // TODO(asiva): Get rid of this function once we have predefined names for
189 ASSERT(raw_class->IsHeapObject()); 189 // the shared classes and set that up in the name field.
190 if (raw_class == class_class()) { 190 const char* Object::GetSingletonClassName(intptr_t class_id) {
191 return kClassClass; 191 switch (class_id) {
192 } else if (raw_class == null_class()) { 192 case kClassCid: return "Class";
193 return kNullClass; 193 case kNullCid: return "Null";
194 } else if (raw_class == dynamic_class()) { 194 case kDynamicCid: return "Dynamic";
195 return kDynamicClass; 195 case kVoidCid: return "void";
196 } else if (raw_class == void_class()) { 196 case kUnresolvedClassCid: return "UnresolvedClass";
197 return kVoidClass; 197 case kTypeCid: return "Type";
198 } else if (raw_class == unresolved_class_class()) { 198 case kTypeParameterCid: return "TypeParameter";
199 return kUnresolvedClassClass; 199 case kTypeArgumentsCid: return "TypeArguments";
200 } else if (raw_class == type_class()) { 200 case kInstantiatedTypeArgumentsCid: return "InstantiatedTypeArguments";
201 return kTypeClass; 201 case kFunctionCid: return "Function";
202 } else if (raw_class == type_parameter_class()) { 202 case kFieldCid: return "Field";
203 return kTypeParameterClass; 203 case kLiteralTokenCid: return "LiteralToken";
204 } else if (raw_class == type_arguments_class()) { 204 case kTokenStreamCid: return "TokenStream";
205 return kTypeArgumentsClass; 205 case kScriptCid: return "Script";
206 } else if (raw_class == instantiated_type_arguments_class()) { 206 case kLibraryCid: return "Library";
207 return kInstantiatedTypeArgumentsClass; 207 case kLibraryPrefixCid: return "LibraryPrefix";
208 } else if (raw_class == function_class()) { 208 case kCodeCid: return "Code";
209 return kFunctionClass; 209 case kInstructionsCid: return "Instructions";
210 } else if (raw_class == field_class()) { 210 case kPcDescriptorsCid: return "PcDescriptors";
211 return kFieldClass; 211 case kStackmapCid: return "Stackmap";
212 } else if (raw_class == literal_token_class()) { 212 case kLocalVarDescriptorsCid: return "LocalVarDescriptors";
213 return kLiteralTokenClass; 213 case kExceptionHandlersCid: return "ExceptionHandlers";
214 } else if (raw_class == token_stream_class()) { 214 case kContextCid: return "Context";
215 return kTokenStreamClass; 215 case kContextScopeCid: return "ContextScope";
216 } else if (raw_class == script_class()) { 216 case kICDataCid: return "ICData";
217 return kScriptClass; 217 case kSubtypeTestCacheCid: return "SubtypeTestCache";
218 } else if (raw_class == library_class()) { 218 case kApiErrorCid: return "ApiError";
219 return kLibraryClass; 219 case kLanguageErrorCid: return "LanguageError";
220 } else if (raw_class == library_prefix_class()) { 220 case kUnhandledExceptionCid: return "UnhandledException";
221 return kLibraryPrefixClass; 221 case kUnwindErrorCid: return "UnwindError";
222 } else if (raw_class == code_class()) {
223 return kCodeClass;
224 } else if (raw_class == instructions_class()) {
225 return kInstructionsClass;
226 } else if (raw_class == pc_descriptors_class()) {
227 return kPcDescriptorsClass;
228 } else if (raw_class == stackmap_class()) {
229 return kStackmapClass;
230 } else if (raw_class == var_descriptors_class()) {
231 return kLocalVarDescriptorsClass;
232 } else if (raw_class == exception_handlers_class()) {
233 return kExceptionHandlersClass;
234 } else if (raw_class == deopt_info_class()) {
235 return kDeoptInfoClass;
236 } else if (raw_class == context_class()) {
237 return kContextClass;
238 } else if (raw_class == context_scope_class()) {
239 return kContextScopeClass;
240 } else if (raw_class == icdata_class()) {
241 return kICDataClass;
242 } else if (raw_class == subtypetestcache_class()) {
243 return kSubtypeTestCacheClass;
244 } else if (raw_class == api_error_class()) {
245 return kApiErrorClass;
246 } else if (raw_class == language_error_class()) {
247 return kLanguageErrorClass;
248 } else if (raw_class == unhandled_exception_class()) {
249 return kUnhandledExceptionClass;
250 } else if (raw_class == unwind_error_class()) {
251 return kUnwindErrorClass;
252 }
253 return kInvalidIndex;
254 }
255
256
257 RawClass* Object::GetSingletonClass(int index) {
258 switch (index) {
259 case kClassClass: return class_class();
260 case kNullClass: return null_class();
261 case kDynamicClass: return dynamic_class();
262 case kVoidClass: return void_class();
263 case kUnresolvedClassClass: return unresolved_class_class();
264 case kTypeClass: return type_class();
265 case kTypeParameterClass: return type_parameter_class();
266 case kTypeArgumentsClass: return type_arguments_class();
267 case kInstantiatedTypeArgumentsClass:
268 return instantiated_type_arguments_class();
269 case kFunctionClass: return function_class();
270 case kFieldClass: return field_class();
271 case kLiteralTokenClass: return literal_token_class();
272 case kTokenStreamClass: return token_stream_class();
273 case kScriptClass: return script_class();
274 case kLibraryClass: return library_class();
275 case kLibraryPrefixClass: return library_prefix_class();
276 case kCodeClass: return code_class();
277 case kInstructionsClass: return instructions_class();
278 case kPcDescriptorsClass: return pc_descriptors_class();
279 case kStackmapClass: return stackmap_class();
280 case kLocalVarDescriptorsClass: return var_descriptors_class();
281 case kExceptionHandlersClass: return exception_handlers_class();
282 case kDeoptInfoClass: return deopt_info_class();
283 case kContextClass: return context_class();
284 case kContextScopeClass: return context_scope_class();
285 case kICDataClass: return icdata_class();
286 case kSubtypeTestCacheClass: return subtypetestcache_class();
287 case kApiErrorClass: return api_error_class();
288 case kLanguageErrorClass: return language_error_class();
289 case kUnhandledExceptionClass: return unhandled_exception_class();
290 case kUnwindErrorClass: return unwind_error_class();
291 default: break;
292 }
293 UNREACHABLE();
294 return reinterpret_cast<RawClass*>(kHeapObjectTag); // return RAW_NULL.
295 }
296
297
298 const char* Object::GetSingletonClassName(int index) {
299 switch (index) {
300 case kClassClass: return "Class";
301 case kNullClass: return "Null";
302 case kDynamicClass: return "Dynamic";
303 case kVoidClass: return "void";
304 case kUnresolvedClassClass: return "UnresolvedClass";
305 case kTypeClass: return "Type";
306 case kTypeParameterClass: return "TypeParameter";
307 case kTypeArgumentsClass: return "TypeArguments";
308 case kInstantiatedTypeArgumentsClass: return "InstantiatedTypeArguments";
309 case kFunctionClass: return "Function";
310 case kFieldClass: return "Field";
311 case kLiteralTokenClass: return "LiteralToken";
312 case kTokenStreamClass: return "TokenStream";
313 case kScriptClass: return "Script";
314 case kLibraryClass: return "Library";
315 case kLibraryPrefixClass: return "LibraryPrefix";
316 case kCodeClass: return "Code";
317 case kInstructionsClass: return "Instructions";
318 case kPcDescriptorsClass: return "PcDescriptors";
319 case kStackmapClass: return "Stackmap";
320 case kLocalVarDescriptorsClass: return "LocalVarDescriptors";
321 case kExceptionHandlersClass: return "ExceptionHandlers";
322 case kDeoptInfoClass: return "DeoptInfo";
323 case kContextClass: return "Context";
324 case kContextScopeClass: return "ContextScope";
325 case kICDataClass: return "ICData";
326 case kSubtypeTestCacheClass: return "SubtypeTestCache";
327 case kApiErrorClass: return "ApiError";
328 case kLanguageErrorClass: return "LanguageError";
329 case kUnhandledExceptionClass: return "UnhandledException";
330 case kUnwindErrorClass: return "UnwindError";
331 default: break; 222 default: break;
332 } 223 }
333 UNREACHABLE(); 224 UNREACHABLE();
334 return NULL; 225 return NULL;
335 } 226 }
336 227
337 228
338 void Object::InitOnce() { 229 void Object::InitOnce() {
339 // TODO(iposva): NoGCScope needs to be added here. 230 // TODO(iposva): NoGCScope needs to be added here.
340 ASSERT(class_class() == null_); 231 ASSERT(class_class() == null_);
341 // Initialize the static vtable values. 232 // Initialize the static vtable values.
342 { 233 {
343 Object fake_object; 234 Object fake_object;
344 Smi fake_smi; 235 Smi fake_smi;
345 Object::handle_vtable_ = fake_object.vtable(); 236 Object::handle_vtable_ = fake_object.vtable();
346 Smi::handle_vtable_ = fake_smi.vtable(); 237 Smi::handle_vtable_ = fake_smi.vtable();
347 } 238 }
348 239
349 Isolate* isolate = Isolate::Current(); 240 Isolate* isolate = Isolate::Current();
350 Heap* heap = isolate->heap(); 241 Heap* heap = isolate->heap();
351 // Allocate and initialize the null instance, except its class_ field. 242 // Allocate and initialize the null instance, except its class_ field.
352 // 'null_' must be the first object allocated as it is used in allocation to 243 // 'null_' must be the first object allocated as it is used in allocation to
353 // clear the object. 244 // clear the object.
354 { 245 {
355 uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld); 246 uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld);
356 null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag); 247 null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag);
357 // The call below is using 'null_' to initialize itself. 248 // The call below is using 'null_' to initialize itself.
358 InitializeObject(address, kNullClassId, Instance::InstanceSize()); 249 InitializeObject(address, kNullCid, Instance::InstanceSize());
359 } 250 }
360 251
361 // Initialize object_store empty array to null_ in order to be able to check 252 // Initialize object_store empty array to null_ in order to be able to check
362 // if the empty array was allocated (RAW_NULL is not available). 253 // if the empty array was allocated (RAW_NULL is not available).
363 isolate->object_store()->set_empty_array(Array::Handle()); 254 isolate->object_store()->set_empty_array(Array::Handle());
364 255
365 Class& cls = Class::Handle(); 256 Class& cls = Class::Handle();
366 257
367 // Allocate and initialize the class class. 258 // Allocate and initialize the class class.
368 { 259 {
369 intptr_t size = Class::InstanceSize(); 260 intptr_t size = Class::InstanceSize();
370 uword address = heap->Allocate(size, Heap::kOld); 261 uword address = heap->Allocate(size, Heap::kOld);
371 class_class_ = reinterpret_cast<RawClass*>(address + kHeapObjectTag); 262 class_class_ = reinterpret_cast<RawClass*>(address + kHeapObjectTag);
372 InitializeObject(address, Class::kInstanceKind, size); 263 InitializeObject(address, Class::kClassId, size);
373 264
374 Class fake; 265 Class fake;
375 // Initialization from Class::New<Class>. 266 // Initialization from Class::New<Class>.
376 // Directly set raw_ to break a circular dependency: SetRaw will attempt 267 // Directly set raw_ to break a circular dependency: SetRaw will attempt
377 // to lookup class class in the class table where it is not registered yet. 268 // to lookup class class in the class table where it is not registered yet.
378 cls.raw_ = class_class_; 269 cls.raw_ = class_class_;
379 cls.set_handle_vtable(fake.vtable()); 270 cls.set_handle_vtable(fake.vtable());
380 cls.set_instance_size(Class::InstanceSize()); 271 cls.set_instance_size(Class::InstanceSize());
381 cls.set_next_field_offset(Class::InstanceSize()); 272 cls.set_next_field_offset(Class::InstanceSize());
382 cls.set_instance_kind(Class::kInstanceKind); 273 cls.set_id(Class::kClassId);
383 cls.set_id(Class::kInstanceKind);
384 cls.raw_ptr()->is_const_ = false; 274 cls.raw_ptr()->is_const_ = false;
385 cls.raw_ptr()->is_interface_ = false; 275 cls.raw_ptr()->is_interface_ = false;
386 cls.set_is_finalized(); 276 cls.set_is_finalized();
387 cls.raw_ptr()->type_arguments_instance_field_offset_ = 277 cls.raw_ptr()->type_arguments_instance_field_offset_ =
388 Class::kNoTypeArguments; 278 Class::kNoTypeArguments;
389 cls.raw_ptr()->num_native_fields_ = 0; 279 cls.raw_ptr()->num_native_fields_ = 0;
390 cls.InitEmptyFields(); 280 cls.InitEmptyFields();
391 isolate->class_table()->Register(cls); 281 isolate->class_table()->Register(cls);
392 } 282 }
393 283
394 // Allocate and initialize the null class. 284 // Allocate and initialize the null class.
395 cls = Class::New<Instance>(kNullClassId); 285 cls = Class::New<Instance>(kNullCid);
396 cls.set_is_finalized(); 286 cls.set_is_finalized();
397 null_class_ = cls.raw(); 287 null_class_ = cls.raw();
398 288
399 // Allocate and initialize the free list element class. 289 // Allocate and initialize the free list element class.
400 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); 290 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement);
401 cls.set_is_finalized(); 291 cls.set_is_finalized();
402 292
403 // Allocate and initialize the sentinel values of Null class. 293 // Allocate and initialize the sentinel values of Null class.
404 { 294 {
405 Instance& sentinel = Instance::Handle(); 295 Instance& sentinel = Instance::Handle();
406 sentinel ^= 296 sentinel ^=
407 Object::Allocate(kNullClassId, Instance::InstanceSize(), Heap::kOld); 297 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld);
408 sentinel_ = sentinel.raw(); 298 sentinel_ = sentinel.raw();
409 299
410 Instance& transition_sentinel = Instance::Handle(); 300 Instance& transition_sentinel = Instance::Handle();
411 transition_sentinel ^= 301 transition_sentinel ^=
412 Object::Allocate(kNullClassId, Instance::InstanceSize(), Heap::kOld); 302 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld);
413 transition_sentinel_ = transition_sentinel.raw(); 303 transition_sentinel_ = transition_sentinel.raw();
414 } 304 }
415 305
416 // The interface "Dynamic" is not a VM internal class. It is the type class of 306 // The interface "Dynamic" is not a VM internal class. It is the type class of
417 // the "unknown type". For efficiency, we allocate it in the VM isolate. 307 // the "unknown type". For efficiency, we allocate it in the VM isolate.
418 // Therefore, it cannot have a heap allocated name (the name is hard coded, 308 // Therefore, it cannot have a heap allocated name (the name is hard coded,
419 // see GetSingletonClassIndex) and its array fields cannot be set to the empty 309 // see GetSingletonClassName) and its array fields cannot be set to the empty
420 // array, but remain null. 310 // array, but remain null.
421 // 311 //
422 // TODO(turnidge): Once the empty array is allocated in the vm 312 // TODO(turnidge): Once the empty array is allocated in the vm
423 // isolate, use it here. 313 // isolate, use it here.
424 cls = Class::New<Instance>(kDynamicClassId); 314 cls = Class::New<Instance>(kDynamicCid);
425 cls.set_is_finalized(); 315 cls.set_is_finalized();
426 cls.set_is_interface(); 316 cls.set_is_interface();
427 dynamic_class_ = cls.raw(); 317 dynamic_class_ = cls.raw();
428 318
429 // Allocate the remaining VM internal classes. 319 // Allocate the remaining VM internal classes.
430 cls = Class::New<UnresolvedClass>(); 320 cls = Class::New<UnresolvedClass>();
431 unresolved_class_class_ = cls.raw(); 321 unresolved_class_class_ = cls.raw();
432 322
433 cls = Class::New<Instance>(kVoidClassId); 323 cls = Class::New<Instance>(kVoidCid);
434 cls.set_is_finalized(); 324 cls.set_is_finalized();
435 void_class_ = cls.raw(); 325 void_class_ = cls.raw();
436 326
437 cls = Class::New<Type>(); 327 cls = Class::New<Type>();
438 type_class_ = cls.raw(); 328 type_class_ = cls.raw();
439 329
440 cls = Class::New<TypeParameter>(); 330 cls = Class::New<TypeParameter>();
441 type_parameter_class_ = cls.raw(); 331 type_parameter_class_ = cls.raw();
442 332
443 cls = Class::New<TypeArguments>(); 333 cls = Class::New<TypeArguments>();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 404
515 ASSERT(class_class() != null_); 405 ASSERT(class_class() != null_);
516 406
517 // Pre-allocate the Array and OneByteString class in the vm isolate so that 407 // Pre-allocate the Array and OneByteString class in the vm isolate so that
518 // we can create a symbol table and populate it with some frequently used 408 // we can create a symbol table and populate it with some frequently used
519 // strings as symbols. 409 // strings as symbols.
520 cls = Class::New<Array>(); 410 cls = Class::New<Array>();
521 isolate->object_store()->set_array_class(cls); 411 isolate->object_store()->set_array_class(cls);
522 cls = Class::New<OneByteString>(); 412 cls = Class::New<OneByteString>();
523 isolate->object_store()->set_one_byte_string_class(cls); 413 isolate->object_store()->set_one_byte_string_class(cls);
524
525 // TODO(asiva): Assign the names of shared classes instead of relying on the
526 // lookup switch in Object::GetSingletonClassName.
527 } 414 }
528 415
529 416
530 RawClass* Object::CreateAndRegisterInterface(const char* cname, 417 RawClass* Object::CreateAndRegisterInterface(const char* cname,
531 const Script& script, 418 const Script& script,
532 const Library& lib) { 419 const Library& lib) {
533 const String& name = String::Handle(Symbols::New(cname)); 420 const String& name = String::Handle(Symbols::New(cname));
534 const Class& cls = Class::Handle( 421 const Class& cls = Class::Handle(
535 Class::NewInterface(name, script, Scanner::kDummyTokenIndex)); 422 Class::NewInterface(name, script, Scanner::kDummyTokenIndex));
536 lib.AddClass(cls); 423 lib.AddClass(cls);
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 bool_value = Bool::New(false); 954 bool_value = Bool::New(false);
1068 object_store->set_false_value(bool_value); 955 object_store->set_false_value(bool_value);
1069 } 956 }
1070 957
1071 958
1072 void Object::Print() const { 959 void Object::Print() const {
1073 OS::Print("%s\n", ToCString()); 960 OS::Print("%s\n", ToCString());
1074 } 961 }
1075 962
1076 963
1077 void Object::InitializeObject(uword address, intptr_t index, intptr_t size) { 964 void Object::InitializeObject(uword address, intptr_t class_id, intptr_t size) {
1078 // TODO(iposva): Get a proper halt instruction from the assembler which 965 // TODO(iposva): Get a proper halt instruction from the assembler which
1079 // would be needed here for code objects. 966 // would be needed here for code objects.
1080 uword initial_value = reinterpret_cast<uword>(null_); 967 uword initial_value = reinterpret_cast<uword>(null_);
1081 uword cur = address; 968 uword cur = address;
1082 uword end = address + size; 969 uword end = address + size;
1083 while (cur < end) { 970 while (cur < end) {
1084 *reinterpret_cast<uword*>(cur) = initial_value; 971 *reinterpret_cast<uword*>(cur) = initial_value;
1085 cur += kWordSize; 972 cur += kWordSize;
1086 } 973 }
1087 uword tags = 0; 974 uword tags = 0;
1088 ASSERT(index != kIllegalObjectKind); 975 ASSERT(class_id != kIllegalCid);
1089 tags = RawObject::ClassIdTag::update(index, tags); 976 tags = RawObject::ClassIdTag::update(class_id, tags);
1090 tags = RawObject::SizeTag::update(size, tags); 977 tags = RawObject::SizeTag::update(size, tags);
1091 reinterpret_cast<RawObject*>(address)->tags_ = tags; 978 reinterpret_cast<RawObject*>(address)->tags_ = tags;
1092 } 979 }
1093 980
1094 981
1095 RawObject* Object::Allocate(intptr_t cls_id, 982 RawObject* Object::Allocate(intptr_t cls_id,
1096 intptr_t size, 983 intptr_t size,
1097 Heap::Space space) { 984 Heap::Space space) {
1098 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 985 ASSERT(Utils::IsAligned(size, kObjectAlignment));
1099 Isolate* isolate = Isolate::Current(); 986 Isolate* isolate = Isolate::Current();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 } 1034 }
1148 return raw_obj; 1035 return raw_obj;
1149 } 1036 }
1150 1037
1151 1038
1152 RawString* Class::Name() const { 1039 RawString* Class::Name() const {
1153 if (raw_ptr()->name_ != String::null()) { 1040 if (raw_ptr()->name_ != String::null()) {
1154 return raw_ptr()->name_; 1041 return raw_ptr()->name_;
1155 } 1042 }
1156 ASSERT(class_class() != Class::null()); // class_class_ should be set up. 1043 ASSERT(class_class() != Class::null()); // class_class_ should be set up.
1157 intptr_t index = GetSingletonClassIndex(raw()); 1044 return Symbols::New(GetSingletonClassName(raw_ptr()->id_));
1158 return Symbols::New(GetSingletonClassName(index));
1159 } 1045 }
1160 1046
1161 1047
1162 RawString* Class::UserVisibleName() const { 1048 RawString* Class::UserVisibleName() const {
1163 if (FLAG_show_internal_names) { 1049 if (FLAG_show_internal_names) {
1164 return Name(); 1050 return Name();
1165 } 1051 }
1166 switch (id()) { 1052 switch (id()) {
1167 case kInteger: 1053 case kIntegerCid:
1168 case kSmi: 1054 case kSmiCid:
1169 case kMint: 1055 case kMintCid:
1170 case kBigint: 1056 case kBigintCid:
1171 return Symbols::New("int"); 1057 return Symbols::New("int");
1172 case kDouble: 1058 case kDoubleCid:
1173 return Symbols::New("double"); 1059 return Symbols::New("double");
1174 case kOneByteString: 1060 case kOneByteStringCid:
1175 case kTwoByteString: 1061 case kTwoByteStringCid:
1176 case kFourByteString: 1062 case kFourByteStringCid:
1177 case kExternalOneByteString: 1063 case kExternalOneByteStringCid:
1178 case kExternalTwoByteString: 1064 case kExternalTwoByteStringCid:
1179 case kExternalFourByteString: 1065 case kExternalFourByteStringCid:
1180 return Symbols::New("String"); 1066 return Symbols::New("String");
1181 case kBool: 1067 case kBoolCid:
1182 return Symbols::New("bool"); 1068 return Symbols::New("bool");
1183 case kArray: 1069 case kArrayCid:
1184 case kImmutableArray: 1070 case kImmutableArrayCid:
1185 case kGrowableObjectArray: 1071 case kGrowableObjectArrayCid:
1186 return Symbols::New("List"); 1072 return Symbols::New("List");
1187 case kInt8Array: 1073 case kInt8ArrayCid:
1188 case kExternalInt8Array: 1074 case kExternalInt8ArrayCid:
1189 return Symbols::New("Int8List"); 1075 return Symbols::New("Int8List");
1190 case kUint8Array: 1076 case kUint8ArrayCid:
1191 case kExternalUint8Array: 1077 case kExternalUint8ArrayCid:
1192 return Symbols::New("Uint8List"); 1078 return Symbols::New("Uint8List");
1193 case kInt16Array: 1079 case kInt16ArrayCid:
1194 case kExternalInt16Array: 1080 case kExternalInt16ArrayCid:
1195 return Symbols::New("Int16List"); 1081 return Symbols::New("Int16List");
1196 case kUint16Array: 1082 case kUint16ArrayCid:
1197 case kExternalUint16Array: 1083 case kExternalUint16ArrayCid:
1198 return Symbols::New("Uint16List"); 1084 return Symbols::New("Uint16List");
1199 case kInt32Array: 1085 case kInt32ArrayCid:
1200 case kExternalInt32Array: 1086 case kExternalInt32ArrayCid:
1201 return Symbols::New("Int32List"); 1087 return Symbols::New("Int32List");
1202 case kUint32Array: 1088 case kUint32ArrayCid:
1203 case kExternalUint32Array: 1089 case kExternalUint32ArrayCid:
1204 return Symbols::New("Uint32List"); 1090 return Symbols::New("Uint32List");
1205 case kInt64Array: 1091 case kInt64ArrayCid:
1206 case kExternalInt64Array: 1092 case kExternalInt64ArrayCid:
1207 return Symbols::New("Int64List"); 1093 return Symbols::New("Int64List");
1208 case kUint64Array: 1094 case kUint64ArrayCid:
1209 case kExternalUint64Array: 1095 case kExternalUint64ArrayCid:
1210 return Symbols::New("Uint64List"); 1096 return Symbols::New("Uint64List");
1211 case kFloat32Array: 1097 case kFloat32ArrayCid:
1212 case kExternalFloat32Array: 1098 case kExternalFloat32ArrayCid:
1213 return Symbols::New("Float32List"); 1099 return Symbols::New("Float32List");
1214 case kFloat64Array: 1100 case kFloat64ArrayCid:
1215 case kExternalFloat64Array: 1101 case kExternalFloat64ArrayCid:
1216 return Symbols::New("Float64List"); 1102 return Symbols::New("Float64List");
1217 default: 1103 default:
1218 const String& name = String::Handle(Name()); 1104 const String& name = String::Handle(Name());
1219 return IdentifierPrettyName(name); 1105 return IdentifierPrettyName(name);
1220 } 1106 }
1221 UNREACHABLE(); 1107 UNREACHABLE();
1222 } 1108 }
1223 1109
1224 1110
1225 RawType* Class::SignatureType() const { 1111 RawType* Class::SignatureType() const {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 ASSERT(!signature_type.IsFinalized()); 1146 ASSERT(!signature_type.IsFinalized());
1261 return signature_type.raw(); 1147 return signature_type.raw();
1262 } 1148 }
1263 1149
1264 1150
1265 template <class FakeObject> 1151 template <class FakeObject>
1266 RawClass* Class::New() { 1152 RawClass* Class::New() {
1267 ASSERT(Object::class_class() != Class::null()); 1153 ASSERT(Object::class_class() != Class::null());
1268 Class& result = Class::Handle(); 1154 Class& result = Class::Handle();
1269 { 1155 {
1270 RawObject* raw = Object::Allocate(Class::kInstanceKind, 1156 RawObject* raw = Object::Allocate(Class::kClassId,
1271 Class::InstanceSize(), 1157 Class::InstanceSize(),
1272 Heap::kOld); 1158 Heap::kOld);
1273 NoGCScope no_gc; 1159 NoGCScope no_gc;
1274 result ^= raw; 1160 result ^= raw;
1275 } 1161 }
1276 FakeObject fake; 1162 FakeObject fake;
1277 result.set_handle_vtable(fake.vtable()); 1163 result.set_handle_vtable(fake.vtable());
1278 result.set_instance_size(FakeObject::InstanceSize()); 1164 result.set_instance_size(FakeObject::InstanceSize());
1279 result.set_next_field_offset(FakeObject::InstanceSize()); 1165 result.set_next_field_offset(FakeObject::InstanceSize());
1280 result.set_instance_kind(FakeObject::kInstanceKind); 1166 result.set_id((FakeObject::kClassId != kInstanceCid &&
1281 result.set_id((FakeObject::kInstanceKind != kInstance) ? 1167 FakeObject::kClassId != kClosureCid) ?
1282 FakeObject::kInstanceKind : kIllegalObjectKind); 1168 FakeObject::kClassId : kIllegalCid);
1283 result.raw_ptr()->is_const_ = false; 1169 result.raw_ptr()->is_const_ = false;
1284 result.raw_ptr()->is_interface_ = false; 1170 result.raw_ptr()->is_interface_ = false;
1285 // VM backed classes are almost ready: run checks and resolve class 1171 // VM backed classes are almost ready: run checks and resolve class
1286 // references, but do not recompute size. 1172 // references, but do not recompute size.
1287 result.raw_ptr()->class_state_ = RawClass::kPreFinalized; 1173 result.raw_ptr()->class_state_ = RawClass::kPreFinalized;
1288 result.raw_ptr()->type_arguments_instance_field_offset_ = kNoTypeArguments; 1174 result.raw_ptr()->type_arguments_instance_field_offset_ = kNoTypeArguments;
1289 result.raw_ptr()->num_native_fields_ = 0; 1175 result.raw_ptr()->num_native_fields_ = 0;
1290 result.raw_ptr()->token_pos_ = Scanner::kDummyTokenIndex; 1176 result.raw_ptr()->token_pos_ = Scanner::kDummyTokenIndex;
1291 result.InitEmptyFields(); 1177 result.InitEmptyFields();
1292 Isolate::Current()->class_table()->Register(result); 1178 Isolate::Current()->class_table()->Register(result);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 // The value of static fields is already initialized to null. 1483 // The value of static fields is already initialized to null.
1598 StorePointer(&raw_ptr()->fields_, value.raw()); 1484 StorePointer(&raw_ptr()->fields_, value.raw());
1599 } 1485 }
1600 1486
1601 1487
1602 template <class FakeInstance> 1488 template <class FakeInstance>
1603 RawClass* Class::New(intptr_t index) { 1489 RawClass* Class::New(intptr_t index) {
1604 ASSERT(Object::class_class() != Class::null()); 1490 ASSERT(Object::class_class() != Class::null());
1605 Class& result = Class::Handle(); 1491 Class& result = Class::Handle();
1606 { 1492 {
1607 RawObject* raw = Object::Allocate(Class::kInstanceKind, 1493 RawObject* raw = Object::Allocate(Class::kClassId,
1608 Class::InstanceSize(), 1494 Class::InstanceSize(),
1609 Heap::kOld); 1495 Heap::kOld);
1610 NoGCScope no_gc; 1496 NoGCScope no_gc;
1611 result ^= raw; 1497 result ^= raw;
1612 } 1498 }
1613 FakeInstance fake; 1499 FakeInstance fake;
1614 ASSERT(fake.IsInstance()); 1500 ASSERT(fake.IsInstance());
1615 result.set_handle_vtable(fake.vtable()); 1501 result.set_handle_vtable(fake.vtable());
1616 result.set_instance_size(FakeInstance::InstanceSize()); 1502 result.set_instance_size(FakeInstance::InstanceSize());
1617 result.set_next_field_offset(FakeInstance::InstanceSize()); 1503 result.set_next_field_offset(FakeInstance::InstanceSize());
1618 result.set_instance_kind(FakeInstance::kInstanceKind);
1619 result.set_id(index); 1504 result.set_id(index);
1620 result.raw_ptr()->is_const_ = false; 1505 result.raw_ptr()->is_const_ = false;
1621 result.raw_ptr()->is_interface_ = false; 1506 result.raw_ptr()->is_interface_ = false;
1622 result.raw_ptr()->class_state_ = RawClass::kAllocated; 1507 result.raw_ptr()->class_state_ = RawClass::kAllocated;
1623 result.raw_ptr()->type_arguments_instance_field_offset_ = kNoTypeArguments; 1508 result.raw_ptr()->type_arguments_instance_field_offset_ = kNoTypeArguments;
1624 result.raw_ptr()->num_native_fields_ = 0; 1509 result.raw_ptr()->num_native_fields_ = 0;
1625 result.InitEmptyFields(); 1510 result.InitEmptyFields();
1626 Isolate::Current()->class_table()->Register(result); 1511 Isolate::Current()->class_table()->Register(result);
1627 return result.raw(); 1512 return result.raw();
1628 } 1513 }
1629 1514
1630 1515
1631 template <class FakeInstance> 1516 template <class FakeInstance>
1632 RawClass* Class::New(const String& name, 1517 RawClass* Class::New(const String& name,
1633 const Script& script, 1518 const Script& script,
1634 intptr_t token_pos) { 1519 intptr_t token_pos) {
1635 Class& result = Class::Handle(New<FakeInstance>(kIllegalObjectKind)); 1520 Class& result = Class::Handle(New<FakeInstance>(kIllegalCid));
1636 result.set_name(name); 1521 result.set_name(name);
1637 result.set_script(script); 1522 result.set_script(script);
1638 result.set_token_pos(token_pos); 1523 result.set_token_pos(token_pos);
1639 return result.raw(); 1524 return result.raw();
1640 } 1525 }
1641 1526
1642 1527
1643 RawClass* Class::New(const String& name, 1528 RawClass* Class::New(const String& name,
1644 const Script& script, 1529 const Script& script,
1645 intptr_t token_pos) { 1530 intptr_t token_pos) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 // Cache the signature type as the first canonicalized type in result. 1591 // Cache the signature type as the first canonicalized type in result.
1707 const Type& signature_type = Type::Handle(result.SignatureType()); 1592 const Type& signature_type = Type::Handle(result.SignatureType());
1708 ASSERT(!signature_type.IsFinalized()); 1593 ASSERT(!signature_type.IsFinalized());
1709 const Array& new_canonical_types = Array::Handle(Array::New(1, Heap::kOld)); 1594 const Array& new_canonical_types = Array::Handle(Array::New(1, Heap::kOld));
1710 new_canonical_types.SetAt(0, signature_type); 1595 new_canonical_types.SetAt(0, signature_type);
1711 result.set_canonical_types(new_canonical_types); 1596 result.set_canonical_types(new_canonical_types);
1712 return result.raw(); 1597 return result.raw();
1713 } 1598 }
1714 1599
1715 1600
1716 RawClass* Class::GetClass(ObjectKind kind) { 1601 RawClass* Class::GetClass(intptr_t class_id, bool is_signature_class) {
1717 ObjectStore* object_store = Isolate::Current()->object_store(); 1602 if (class_id >= kIntegerCid && class_id <= kJSRegExpCid) {
1718 switch (kind) { 1603 return Isolate::Current()->class_table()->At(class_id);
1719 case kInteger: 1604 }
1720 ASSERT(object_store->integer_implementation_class() != Class::null()); 1605 if (class_id >= kNumPredefinedCids) {
1721 return object_store->integer_implementation_class(); 1606 if (is_signature_class) {
1722 case kSmi:
1723 ASSERT(object_store->smi_class() != Class::null());
1724 return object_store->smi_class();
1725 case kMint:
1726 ASSERT(object_store->mint_class() != Class::null());
1727 return object_store->mint_class();
1728 case kBigint:
1729 ASSERT(object_store->bigint_class() != Class::null());
1730 return object_store->bigint_class();
1731 case kDouble:
1732 ASSERT(object_store->double_class() != Class::null());
1733 return object_store->double_class();
1734 case kOneByteString:
1735 ASSERT(object_store->one_byte_string_class() != Class::null());
1736 return object_store->one_byte_string_class();
1737 case kTwoByteString:
1738 ASSERT(object_store->two_byte_string_class() != Class::null());
1739 return object_store->two_byte_string_class();
1740 case kFourByteString:
1741 ASSERT(object_store->four_byte_string_class() != Class::null());
1742 return object_store->four_byte_string_class();
1743 case kExternalOneByteString:
1744 ASSERT(object_store->external_one_byte_string_class() != Class::null());
1745 return object_store->external_one_byte_string_class();
1746 case kExternalTwoByteString:
1747 ASSERT(object_store->external_two_byte_string_class() != Class::null());
1748 return object_store->external_two_byte_string_class();
1749 case kExternalFourByteString:
1750 ASSERT(object_store->external_four_byte_string_class() != Class::null());
1751 return object_store->external_four_byte_string_class();
1752 case kBool:
1753 ASSERT(object_store->bool_class() != Class::null());
1754 return object_store->bool_class();
1755 case kArray:
1756 ASSERT(object_store->array_class() != Class::null());
1757 return object_store->array_class();
1758 case kImmutableArray:
1759 ASSERT(object_store->immutable_array_class() != Class::null());
1760 return object_store->immutable_array_class();
1761 case kGrowableObjectArray:
1762 ASSERT(object_store->growable_object_array_class() != Class::null());
1763 return object_store->growable_object_array_class();
1764 case kInt8Array:
1765 ASSERT(object_store->int8_array_class() != Class::null());
1766 return object_store->int8_array_class();
1767 case kUint8Array:
1768 ASSERT(object_store->uint8_array_class() != Class::null());
1769 return object_store->uint8_array_class();
1770 case kInt16Array:
1771 ASSERT(object_store->int16_array_class() != Class::null());
1772 return object_store->int16_array_class();
1773 case kUint16Array:
1774 ASSERT(object_store->uint16_array_class() != Class::null());
1775 return object_store->uint16_array_class();
1776 case kInt32Array:
1777 ASSERT(object_store->int32_array_class() != Class::null());
1778 return object_store->int32_array_class();
1779 case kUint32Array:
1780 ASSERT(object_store->uint32_array_class() != Class::null());
1781 return object_store->uint32_array_class();
1782 case kInt64Array:
1783 ASSERT(object_store->int64_array_class() != Class::null());
1784 return object_store->int64_array_class();
1785 case kUint64Array:
1786 ASSERT(object_store->uint64_array_class() != Class::null());
1787 return object_store->uint64_array_class();
1788 case kFloat32Array:
1789 ASSERT(object_store->float32_array_class() != Class::null());
1790 return object_store->float32_array_class();
1791 case kFloat64Array:
1792 ASSERT(object_store->float64_array_class() != Class::null());
1793 return object_store->float64_array_class();
1794 case kExternalInt8Array:
1795 ASSERT(object_store->external_int8_array_class() != Class::null());
1796 return object_store->external_int8_array_class();
1797 case kExternalUint8Array:
1798 ASSERT(object_store->external_uint8_array_class() != Class::null());
1799 return object_store->external_uint8_array_class();
1800 case kExternalInt16Array:
1801 ASSERT(object_store->external_int16_array_class() != Class::null());
1802 return object_store->external_int16_array_class();
1803 case kExternalUint16Array:
1804 ASSERT(object_store->external_uint16_array_class() != Class::null());
1805 return object_store->external_uint16_array_class();
1806 case kExternalInt32Array:
1807 ASSERT(object_store->external_int32_array_class() != Class::null());
1808 return object_store->external_int32_array_class();
1809 case kExternalUint32Array:
1810 ASSERT(object_store->external_uint32_array_class() != Class::null());
1811 return object_store->external_uint32_array_class();
1812 case kExternalInt64Array:
1813 ASSERT(object_store->external_int64_array_class() != Class::null());
1814 return object_store->external_int64_array_class();
1815 case kExternalUint64Array:
1816 ASSERT(object_store->external_uint64_array_class() != Class::null());
1817 return object_store->external_uint64_array_class();
1818 case kExternalFloat32Array:
1819 ASSERT(object_store->external_float32_array_class() != Class::null());
1820 return object_store->external_float32_array_class();
1821 case kExternalFloat64Array:
1822 ASSERT(object_store->external_float64_array_class() != Class::null());
1823 return object_store->external_float64_array_class();
1824 case kStacktrace:
1825 ASSERT(object_store->stacktrace_class() != Class::null());
1826 return object_store->stacktrace_class();
1827 case kJSRegExp:
1828 ASSERT(object_store->jsregexp_class() != Class::null());
1829 return object_store->jsregexp_class();
1830 case kClosure:
1831 return Class::New<Closure>(); 1607 return Class::New<Closure>();
1832 case kInstance: 1608 }
1833 return Class::New<Instance>(); 1609 return Class::New<Instance>();
1834 default:
1835 OS::Print("Class::GetClass kind unknown: %d\n", kind);
1836 UNREACHABLE();
1837 } 1610 }
1611 OS::Print("Class::GetClass id unknown: %d\n", class_id);
1612 UNREACHABLE();
1838 return Class::null(); 1613 return Class::null();
1839 } 1614 }
1840 1615
1841 1616
1842 RawClass* Class::NewNativeWrapper(Library* library, 1617 RawClass* Class::NewNativeWrapper(Library* library,
1843 const String& name, 1618 const String& name,
1844 int field_count) { 1619 int field_count) {
1845 Class& cls = Class::Handle(library->LookupClass(name)); 1620 Class& cls = Class::Handle(library->LookupClass(name));
1846 if (cls.IsNull()) { 1621 if (cls.IsNull()) {
1847 cls = New<Instance>(name, Script::Handle(), Scanner::kDummyTokenIndex); 1622 cls = New<Instance>(name, Script::Handle(), Scanner::kDummyTokenIndex);
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New()); 2095 const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New());
2321 type.set_library_prefix(library_prefix); 2096 type.set_library_prefix(library_prefix);
2322 type.set_ident(ident); 2097 type.set_ident(ident);
2323 type.set_token_pos(token_pos); 2098 type.set_token_pos(token_pos);
2324 return type.raw(); 2099 return type.raw();
2325 } 2100 }
2326 2101
2327 2102
2328 RawUnresolvedClass* UnresolvedClass::New() { 2103 RawUnresolvedClass* UnresolvedClass::New() {
2329 ASSERT(Object::unresolved_class_class() != Class::null()); 2104 ASSERT(Object::unresolved_class_class() != Class::null());
2330 RawObject* raw = Object::Allocate(UnresolvedClass::kInstanceKind, 2105 RawObject* raw = Object::Allocate(UnresolvedClass::kClassId,
2331 UnresolvedClass::InstanceSize(), 2106 UnresolvedClass::InstanceSize(),
2332 Heap::kOld); 2107 Heap::kOld);
2333 return reinterpret_cast<RawUnresolvedClass*>(raw); 2108 return reinterpret_cast<RawUnresolvedClass*>(raw);
2334 } 2109 }
2335 2110
2336 2111
2337 void UnresolvedClass::set_token_pos(intptr_t token_pos) const { 2112 void UnresolvedClass::set_token_pos(intptr_t token_pos) const {
2338 ASSERT(token_pos >= 0); 2113 ASSERT(token_pos >= 0);
2339 raw_ptr()->token_pos_ = token_pos; 2114 raw_ptr()->token_pos_ = token_pos;
2340 } 2115 }
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
2969 } 2744 }
2970 2745
2971 2746
2972 void Type::set_arguments(const AbstractTypeArguments& value) const { 2747 void Type::set_arguments(const AbstractTypeArguments& value) const {
2973 StorePointer(&raw_ptr()->arguments_, value.raw()); 2748 StorePointer(&raw_ptr()->arguments_, value.raw());
2974 } 2749 }
2975 2750
2976 2751
2977 RawType* Type::New(Heap::Space space) { 2752 RawType* Type::New(Heap::Space space) {
2978 ASSERT(Object::type_class() != Class::null()); 2753 ASSERT(Object::type_class() != Class::null());
2979 RawObject* raw = Object::Allocate(Type::kInstanceKind, 2754 RawObject* raw = Object::Allocate(Type::kClassId,
2980 Type::InstanceSize(), 2755 Type::InstanceSize(),
2981 space); 2756 space);
2982 return reinterpret_cast<RawType*>(raw); 2757 return reinterpret_cast<RawType*>(raw);
2983 } 2758 }
2984 2759
2985 2760
2986 RawType* Type::New(const Object& clazz, 2761 RawType* Type::New(const Object& clazz,
2987 const AbstractTypeArguments& arguments, 2762 const AbstractTypeArguments& arguments,
2988 intptr_t token_pos, 2763 intptr_t token_pos,
2989 Heap::Space space) { 2764 Heap::Space space) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
3128 ASSERT(IsFinalized()); 2903 ASSERT(IsFinalized());
3129 if (instantiator_type_arguments.IsNull()) { 2904 if (instantiator_type_arguments.IsNull()) {
3130 return Type::DynamicType(); 2905 return Type::DynamicType();
3131 } 2906 }
3132 return instantiator_type_arguments.TypeAt(index()); 2907 return instantiator_type_arguments.TypeAt(index());
3133 } 2908 }
3134 2909
3135 2910
3136 RawTypeParameter* TypeParameter::New() { 2911 RawTypeParameter* TypeParameter::New() {
3137 ASSERT(Object::type_parameter_class() != Class::null()); 2912 ASSERT(Object::type_parameter_class() != Class::null());
3138 RawObject* raw = Object::Allocate(TypeParameter::kInstanceKind, 2913 RawObject* raw = Object::Allocate(TypeParameter::kClassId,
3139 TypeParameter::InstanceSize(), 2914 TypeParameter::InstanceSize(),
3140 Heap::kOld); 2915 Heap::kOld);
3141 return reinterpret_cast<RawTypeParameter*>(raw); 2916 return reinterpret_cast<RawTypeParameter*>(raw);
3142 } 2917 }
3143 2918
3144 2919
3145 RawTypeParameter* TypeParameter::New(const Class& parameterized_class, 2920 RawTypeParameter* TypeParameter::New(const Class& parameterized_class,
3146 intptr_t index, 2921 intptr_t index,
3147 const String& name, 2922 const String& name,
3148 const AbstractType& bound, 2923 const AbstractType& bound,
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
3551 } 3326 }
3552 3327
3553 3328
3554 RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) { 3329 RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) {
3555 if (len < 0 || len > kMaxElements) { 3330 if (len < 0 || len > kMaxElements) {
3556 // This should be caught before we reach here. 3331 // This should be caught before we reach here.
3557 FATAL1("Fatal error in TypeArguments::New: invalid len %ld\n", len); 3332 FATAL1("Fatal error in TypeArguments::New: invalid len %ld\n", len);
3558 } 3333 }
3559 TypeArguments& result = TypeArguments::Handle(); 3334 TypeArguments& result = TypeArguments::Handle();
3560 { 3335 {
3561 RawObject* raw = Object::Allocate(TypeArguments::kInstanceKind, 3336 RawObject* raw = Object::Allocate(TypeArguments::kClassId,
3562 TypeArguments::InstanceSize(len), 3337 TypeArguments::InstanceSize(len),
3563 space); 3338 space);
3564 NoGCScope no_gc; 3339 NoGCScope no_gc;
3565 result ^= raw; 3340 result ^= raw;
3566 // Length must be set before we start storing into the array. 3341 // Length must be set before we start storing into the array.
3567 result.SetLength(len); 3342 result.SetLength(len);
3568 } 3343 }
3569 return result.raw(); 3344 return result.raw();
3570 } 3345 }
3571 3346
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3671 3446
3672 3447
3673 void InstantiatedTypeArguments::set_instantiator_type_arguments( 3448 void InstantiatedTypeArguments::set_instantiator_type_arguments(
3674 const AbstractTypeArguments& value) const { 3449 const AbstractTypeArguments& value) const {
3675 StorePointer(&raw_ptr()->instantiator_type_arguments_, value.raw()); 3450 StorePointer(&raw_ptr()->instantiator_type_arguments_, value.raw());
3676 } 3451 }
3677 3452
3678 3453
3679 RawInstantiatedTypeArguments* InstantiatedTypeArguments::New() { 3454 RawInstantiatedTypeArguments* InstantiatedTypeArguments::New() {
3680 ASSERT(Object::instantiated_type_arguments_class() != Class::null()); 3455 ASSERT(Object::instantiated_type_arguments_class() != Class::null());
3681 RawObject* raw = Object::Allocate(InstantiatedTypeArguments::kInstanceKind, 3456 RawObject* raw = Object::Allocate(InstantiatedTypeArguments::kClassId,
3682 InstantiatedTypeArguments::InstanceSize(), 3457 InstantiatedTypeArguments::InstanceSize(),
3683 Heap::kNew); 3458 Heap::kNew);
3684 return reinterpret_cast<RawInstantiatedTypeArguments*>(raw); 3459 return reinterpret_cast<RawInstantiatedTypeArguments*>(raw);
3685 } 3460 }
3686 3461
3687 3462
3688 RawInstantiatedTypeArguments* InstantiatedTypeArguments::New( 3463 RawInstantiatedTypeArguments* InstantiatedTypeArguments::New(
3689 const AbstractTypeArguments& uninstantiated_type_arguments, 3464 const AbstractTypeArguments& uninstantiated_type_arguments,
3690 const AbstractTypeArguments& instantiator_type_arguments) { 3465 const AbstractTypeArguments& instantiator_type_arguments) {
3691 const InstantiatedTypeArguments& result = 3466 const InstantiatedTypeArguments& result =
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
4199 if (!IsClosureFunction()) { 3974 if (!IsClosureFunction()) {
4200 return false; 3975 return false;
4201 } 3976 }
4202 const Function& parent = Function::Handle(parent_function()); 3977 const Function& parent = Function::Handle(parent_function());
4203 return parent.raw_ptr()->implicit_closure_function_ == raw(); 3978 return parent.raw_ptr()->implicit_closure_function_ == raw();
4204 } 3979 }
4205 3980
4206 3981
4207 RawFunction* Function::New() { 3982 RawFunction* Function::New() {
4208 ASSERT(Object::function_class() != Class::null()); 3983 ASSERT(Object::function_class() != Class::null());
4209 RawObject* raw = Object::Allocate(Function::kInstanceKind, 3984 RawObject* raw = Object::Allocate(Function::kClassId,
4210 Function::InstanceSize(), 3985 Function::InstanceSize(),
4211 Heap::kOld); 3986 Heap::kOld);
4212 return reinterpret_cast<RawFunction*>(raw); 3987 return reinterpret_cast<RawFunction*>(raw);
4213 } 3988 }
4214 3989
4215 3990
4216 RawFunction* Function::New(const String& name, 3991 RawFunction* Function::New(const String& name,
4217 RawFunction::Kind kind, 3992 RawFunction::Kind kind,
4218 bool is_static, 3993 bool is_static,
4219 bool is_const, 3994 bool is_const,
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
4603 4378
4604 4379
4605 void Field::set_type(const AbstractType& value) const { 4380 void Field::set_type(const AbstractType& value) const {
4606 ASSERT(!value.IsNull()); 4381 ASSERT(!value.IsNull());
4607 StorePointer(&raw_ptr()->type_, value.raw()); 4382 StorePointer(&raw_ptr()->type_, value.raw());
4608 } 4383 }
4609 4384
4610 4385
4611 RawField* Field::New() { 4386 RawField* Field::New() {
4612 ASSERT(Object::field_class() != Class::null()); 4387 ASSERT(Object::field_class() != Class::null());
4613 RawObject* raw = Object::Allocate(Field::kInstanceKind, 4388 RawObject* raw = Object::Allocate(Field::kClassId,
4614 Field::InstanceSize(), 4389 Field::InstanceSize(),
4615 Heap::kOld); 4390 Heap::kOld);
4616 return reinterpret_cast<RawField*>(raw); 4391 return reinterpret_cast<RawField*>(raw);
4617 } 4392 }
4618 4393
4619 4394
4620 RawField* Field::New(const String& name, 4395 RawField* Field::New(const String& name,
4621 bool is_static, 4396 bool is_static,
4622 bool is_final, 4397 bool is_final,
4623 bool is_const, 4398 bool is_const,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4669 } 4444 }
4670 4445
4671 4446
4672 void LiteralToken::set_value(const Object& value) const { 4447 void LiteralToken::set_value(const Object& value) const {
4673 StorePointer(&raw_ptr()->value_, value.raw()); 4448 StorePointer(&raw_ptr()->value_, value.raw());
4674 } 4449 }
4675 4450
4676 4451
4677 RawLiteralToken* LiteralToken::New() { 4452 RawLiteralToken* LiteralToken::New() {
4678 ASSERT(Object::literal_token_class() != Class::null()); 4453 ASSERT(Object::literal_token_class() != Class::null());
4679 RawObject* raw = Object::Allocate(LiteralToken::kInstanceKind, 4454 RawObject* raw = Object::Allocate(LiteralToken::kClassId,
4680 LiteralToken::InstanceSize(), 4455 LiteralToken::InstanceSize(),
4681 Heap::kOld); 4456 Heap::kOld);
4682 return reinterpret_cast<RawLiteralToken*>(raw); 4457 return reinterpret_cast<RawLiteralToken*>(raw);
4683 } 4458 }
4684 4459
4685 4460
4686 RawLiteralToken* LiteralToken::New(Token::Kind kind, const String& literal) { 4461 RawLiteralToken* LiteralToken::New(Token::Kind kind, const String& literal) {
4687 const LiteralToken& result = LiteralToken::Handle(LiteralToken::New()); 4462 const LiteralToken& result = LiteralToken::Handle(LiteralToken::New());
4688 result.set_kind(kind); 4463 result.set_kind(kind);
4689 result.set_literal(literal); 4464 result.set_literal(literal);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
4855 4630
4856 4631
4857 RawTokenStream* TokenStream::New(intptr_t len) { 4632 RawTokenStream* TokenStream::New(intptr_t len) {
4858 ASSERT(Object::token_stream_class() != Class::null()); 4633 ASSERT(Object::token_stream_class() != Class::null());
4859 if (len < 0 || len > kMaxElements) { 4634 if (len < 0 || len > kMaxElements) {
4860 // This should be caught before we reach here. 4635 // This should be caught before we reach here.
4861 FATAL1("Fatal error in TokenStream::New: invalid len %ld\n", len); 4636 FATAL1("Fatal error in TokenStream::New: invalid len %ld\n", len);
4862 } 4637 }
4863 TokenStream& result = TokenStream::Handle(); 4638 TokenStream& result = TokenStream::Handle();
4864 { 4639 {
4865 RawObject* raw = Object::Allocate(TokenStream::kInstanceKind, 4640 RawObject* raw = Object::Allocate(TokenStream::kClassId,
4866 TokenStream::InstanceSize(len), 4641 TokenStream::InstanceSize(len),
4867 Heap::kOld); 4642 Heap::kOld);
4868 NoGCScope no_gc; 4643 NoGCScope no_gc;
4869 result ^= raw; 4644 result ^= raw;
4870 result.SetLength(len); 4645 result.SetLength(len);
4871 } 4646 }
4872 return result.raw(); 4647 return result.raw();
4873 } 4648 }
4874 4649
4875 4650
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
5352 if ((snippet_start != -1) && (snippet_end != -1)) { 5127 if ((snippet_start != -1) && (snippet_end != -1)) {
5353 snippet = 5128 snippet =
5354 String::SubString(src, snippet_start, snippet_end - snippet_start); 5129 String::SubString(src, snippet_start, snippet_end - snippet_start);
5355 } 5130 }
5356 return snippet.raw(); 5131 return snippet.raw();
5357 } 5132 }
5358 5133
5359 5134
5360 RawScript* Script::New() { 5135 RawScript* Script::New() {
5361 ASSERT(Object::script_class() != Class::null()); 5136 ASSERT(Object::script_class() != Class::null());
5362 RawObject* raw = Object::Allocate(Script::kInstanceKind, 5137 RawObject* raw = Object::Allocate(Script::kClassId,
5363 Script::InstanceSize(), 5138 Script::InstanceSize(),
5364 Heap::kOld); 5139 Heap::kOld);
5365 return reinterpret_cast<RawScript*>(raw); 5140 return reinterpret_cast<RawScript*>(raw);
5366 } 5141 }
5367 5142
5368 5143
5369 RawScript* Script::New(const String& url, 5144 RawScript* Script::New(const String& url,
5370 const String& source, 5145 const String& source,
5371 RawScript::Kind kind) { 5146 RawScript::Kind kind) {
5372 const Script& result = Script::Handle(Script::New()); 5147 const Script& result = Script::Handle(Script::New());
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
6177 void Library::InitImportedIntoList() const { 5952 void Library::InitImportedIntoList() const {
6178 const Array& imported_into = 5953 const Array& imported_into =
6179 Array::Handle(Array::New(kInitialImportedIntoCapacity, Heap::kOld)); 5954 Array::Handle(Array::New(kInitialImportedIntoCapacity, Heap::kOld));
6180 StorePointer(&raw_ptr()->imported_into_, imported_into.raw()); 5955 StorePointer(&raw_ptr()->imported_into_, imported_into.raw());
6181 raw_ptr()->num_imported_into_ = 0; 5956 raw_ptr()->num_imported_into_ = 0;
6182 } 5957 }
6183 5958
6184 5959
6185 RawLibrary* Library::New() { 5960 RawLibrary* Library::New() {
6186 ASSERT(Object::library_class() != Class::null()); 5961 ASSERT(Object::library_class() != Class::null());
6187 RawObject* raw = Object::Allocate(Library::kInstanceKind, 5962 RawObject* raw = Object::Allocate(Library::kClassId,
6188 Library::InstanceSize(), 5963 Library::InstanceSize(),
6189 Heap::kOld); 5964 Heap::kOld);
6190 return reinterpret_cast<RawLibrary*>(raw); 5965 return reinterpret_cast<RawLibrary*>(raw);
6191 } 5966 }
6192 5967
6193 5968
6194 RawLibrary* Library::NewLibraryHelper(const String& url, 5969 RawLibrary* Library::NewLibraryHelper(const String& url,
6195 bool import_core_lib) { 5970 bool import_core_lib) {
6196 const Library& result = Library::Handle(Library::New()); 5971 const Library& result = Library::Handle(Library::New());
6197 result.StorePointer(&result.raw_ptr()->name_, url.raw()); 5972 result.StorePointer(&result.raw_ptr()->name_, url.raw());
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
6504 if (!resolved_class.IsNull()) { 6279 if (!resolved_class.IsNull()) {
6505 return resolved_class.raw(); 6280 return resolved_class.raw();
6506 } 6281 }
6507 } 6282 }
6508 return Class::null(); 6283 return Class::null();
6509 } 6284 }
6510 6285
6511 6286
6512 RawLibraryPrefix* LibraryPrefix::New() { 6287 RawLibraryPrefix* LibraryPrefix::New() {
6513 ASSERT(Object::library_prefix_class() != Class::null()); 6288 ASSERT(Object::library_prefix_class() != Class::null());
6514 RawObject* raw = Object::Allocate(LibraryPrefix::kInstanceKind, 6289 RawObject* raw = Object::Allocate(LibraryPrefix::kClassId,
6515 LibraryPrefix::InstanceSize(), 6290 LibraryPrefix::InstanceSize(),
6516 Heap::kOld); 6291 Heap::kOld);
6517 return reinterpret_cast<RawLibraryPrefix*>(raw); 6292 return reinterpret_cast<RawLibraryPrefix*>(raw);
6518 } 6293 }
6519 6294
6520 6295
6521 RawLibraryPrefix* LibraryPrefix::New(const String& name, const Library& lib) { 6296 RawLibraryPrefix* LibraryPrefix::New(const String& name, const Library& lib) {
6522 const LibraryPrefix& result = LibraryPrefix::Handle(LibraryPrefix::New()); 6297 const LibraryPrefix& result = LibraryPrefix::Handle(LibraryPrefix::New());
6523 result.set_name(name); 6298 result.set_name(name);
6524 result.set_num_libs(0); 6299 result.set_num_libs(0);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
6636 6411
6637 RawInstructions* Instructions::New(intptr_t size) { 6412 RawInstructions* Instructions::New(intptr_t size) {
6638 ASSERT(Object::instructions_class() != Class::null()); 6413 ASSERT(Object::instructions_class() != Class::null());
6639 if (size < 0 || size > kMaxElements) { 6414 if (size < 0 || size > kMaxElements) {
6640 // This should be caught before we reach here. 6415 // This should be caught before we reach here.
6641 FATAL1("Fatal error in Instructions::New: invalid size %ld\n", size); 6416 FATAL1("Fatal error in Instructions::New: invalid size %ld\n", size);
6642 } 6417 }
6643 Instructions& result = Instructions::Handle(); 6418 Instructions& result = Instructions::Handle();
6644 { 6419 {
6645 uword aligned_size = Instructions::InstanceSize(size); 6420 uword aligned_size = Instructions::InstanceSize(size);
6646 RawObject* raw = Object::Allocate(Instructions::kInstanceKind, 6421 RawObject* raw = Object::Allocate(Instructions::kClassId,
6647 aligned_size, 6422 aligned_size,
6648 Heap::kCode); 6423 Heap::kCode);
6649 NoGCScope no_gc; 6424 NoGCScope no_gc;
6650 // TODO(iposva): Remove premarking once old and code spaces are merged. 6425 // TODO(iposva): Remove premarking once old and code spaces are merged.
6651 raw->SetMarkBit(); 6426 raw->SetMarkBit();
6652 result ^= raw; 6427 result ^= raw;
6653 result.set_size(size); 6428 result.set_size(size);
6654 } 6429 }
6655 return result.raw(); 6430 return result.raw();
6656 } 6431 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
6733 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) { 6508 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) {
6734 ASSERT(Object::pc_descriptors_class() != Class::null()); 6509 ASSERT(Object::pc_descriptors_class() != Class::null());
6735 if (num_descriptors < 0 || num_descriptors > kMaxElements) { 6510 if (num_descriptors < 0 || num_descriptors > kMaxElements) {
6736 // This should be caught before we reach here. 6511 // This should be caught before we reach here.
6737 FATAL1("Fatal error in PcDescriptors::New: invalid num_descriptors %ld\n", 6512 FATAL1("Fatal error in PcDescriptors::New: invalid num_descriptors %ld\n",
6738 num_descriptors); 6513 num_descriptors);
6739 } 6514 }
6740 PcDescriptors& result = PcDescriptors::Handle(); 6515 PcDescriptors& result = PcDescriptors::Handle();
6741 { 6516 {
6742 uword size = PcDescriptors::InstanceSize(num_descriptors); 6517 uword size = PcDescriptors::InstanceSize(num_descriptors);
6743 RawObject* raw = Object::Allocate(PcDescriptors::kInstanceKind, 6518 RawObject* raw = Object::Allocate(PcDescriptors::kClassId,
6744 size, 6519 size,
6745 Heap::kOld); 6520 Heap::kOld);
6746 NoGCScope no_gc; 6521 NoGCScope no_gc;
6747 result ^= raw; 6522 result ^= raw;
6748 result.SetLength(num_descriptors); 6523 result.SetLength(num_descriptors);
6749 } 6524 }
6750 return result.raw(); 6525 return result.raw();
6751 } 6526 }
6752 6527
6753 6528
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
6868 ASSERT(bmap != NULL); 6643 ASSERT(bmap != NULL);
6869 Stackmap& result = Stackmap::Handle(); 6644 Stackmap& result = Stackmap::Handle();
6870 intptr_t size = bmap->SizeInBytes(); 6645 intptr_t size = bmap->SizeInBytes();
6871 if (size < 0 || size > kMaxElements) { 6646 if (size < 0 || size > kMaxElements) {
6872 // This should be caught before we reach here. 6647 // This should be caught before we reach here.
6873 FATAL1("Fatal error in PcDescriptors::New: invalid size %ld\n", size); 6648 FATAL1("Fatal error in PcDescriptors::New: invalid size %ld\n", size);
6874 } 6649 }
6875 { 6650 {
6876 // Stackmap data objects are associated with a code object, allocate them 6651 // Stackmap data objects are associated with a code object, allocate them
6877 // in old generation. 6652 // in old generation.
6878 RawObject* raw = Object::Allocate(Stackmap::kInstanceKind, 6653 RawObject* raw = Object::Allocate(Stackmap::kClassId,
6879 Stackmap::InstanceSize(size), 6654 Stackmap::InstanceSize(size),
6880 Heap::kOld); 6655 Heap::kOld);
6881 NoGCScope no_gc; 6656 NoGCScope no_gc;
6882 result ^= raw; 6657 result ^= raw;
6883 result.set_bitmap_size_in_bytes(size); 6658 result.set_bitmap_size_in_bytes(size);
6884 } 6659 }
6885 result.SetPC(pc_offset); 6660 result.SetPC(pc_offset);
6886 intptr_t bound = bmap->SizeInBits(); 6661 intptr_t bound = bmap->SizeInBits();
6887 for (intptr_t i = 0; i < bound; i++) { 6662 for (intptr_t i = 0; i < bound; i++) {
6888 result.SetBit(i, bmap->Get(i)); 6663 result.SetBit(i, bmap->Get(i));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
6963 RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) { 6738 RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) {
6964 ASSERT(Object::var_descriptors_class() != Class::null()); 6739 ASSERT(Object::var_descriptors_class() != Class::null());
6965 if (num_variables < 0 || num_variables > kMaxElements) { 6740 if (num_variables < 0 || num_variables > kMaxElements) {
6966 // This should be caught before we reach here. 6741 // This should be caught before we reach here.
6967 FATAL1("Fatal error in LocalVarDescriptors::New: " 6742 FATAL1("Fatal error in LocalVarDescriptors::New: "
6968 "invalid num_variables %ld\n", num_variables); 6743 "invalid num_variables %ld\n", num_variables);
6969 } 6744 }
6970 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); 6745 LocalVarDescriptors& result = LocalVarDescriptors::Handle();
6971 { 6746 {
6972 uword size = LocalVarDescriptors::InstanceSize(num_variables); 6747 uword size = LocalVarDescriptors::InstanceSize(num_variables);
6973 RawObject* raw = Object::Allocate(LocalVarDescriptors::kInstanceKind, 6748 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId,
6974 size, 6749 size,
6975 Heap::kOld); 6750 Heap::kOld);
6976 NoGCScope no_gc; 6751 NoGCScope no_gc;
6977 result ^= raw; 6752 result ^= raw;
6978 result.raw_ptr()->length_ = num_variables; 6753 result.raw_ptr()->length_ = num_variables;
6979 } 6754 }
6980 const Array& names = Array::Handle(Array::New(num_variables, Heap::kOld)); 6755 const Array& names = Array::Handle(Array::New(num_variables, Heap::kOld));
6981 result.raw_ptr()->names_ = names.raw(); 6756 result.raw_ptr()->names_ = names.raw();
6982 return result.raw(); 6757 return result.raw();
6983 } 6758 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
7024 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) { 6799 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) {
7025 ASSERT(Object::exception_handlers_class() != Class::null()); 6800 ASSERT(Object::exception_handlers_class() != Class::null());
7026 if (num_handlers < 0 || num_handlers > kMaxElements) { 6801 if (num_handlers < 0 || num_handlers > kMaxElements) {
7027 // This should be caught before we reach here. 6802 // This should be caught before we reach here.
7028 FATAL1("Fatal error in ExceptionHandlers::New: invalid num_handlers %ld\n", 6803 FATAL1("Fatal error in ExceptionHandlers::New: invalid num_handlers %ld\n",
7029 num_handlers); 6804 num_handlers);
7030 } 6805 }
7031 ExceptionHandlers& result = ExceptionHandlers::Handle(); 6806 ExceptionHandlers& result = ExceptionHandlers::Handle();
7032 { 6807 {
7033 uword size = ExceptionHandlers::InstanceSize(num_handlers); 6808 uword size = ExceptionHandlers::InstanceSize(num_handlers);
7034 RawObject* raw = Object::Allocate(ExceptionHandlers::kInstanceKind, 6809 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId,
7035 size, 6810 size,
7036 Heap::kOld); 6811 Heap::kOld);
7037 NoGCScope no_gc; 6812 NoGCScope no_gc;
7038 result ^= raw; 6813 result ^= raw;
7039 result.SetLength(num_handlers); 6814 result.SetLength(num_handlers);
7040 } 6815 }
7041 return result.raw(); 6816 return result.raw();
7042 } 6817 }
7043 6818
7044 6819
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
7108 } 6883 }
7109 return buffer; 6884 return buffer;
7110 } 6885 }
7111 6886
7112 6887
7113 RawDeoptInfo* DeoptInfo::New(intptr_t num_commands) { 6888 RawDeoptInfo* DeoptInfo::New(intptr_t num_commands) {
7114 ASSERT(Object::deopt_info_class() != Class::null()); 6889 ASSERT(Object::deopt_info_class() != Class::null());
7115 DeoptInfo& result = DeoptInfo::Handle(); 6890 DeoptInfo& result = DeoptInfo::Handle();
7116 { 6891 {
7117 uword size = DeoptInfo::InstanceSize(num_commands); 6892 uword size = DeoptInfo::InstanceSize(num_commands);
7118 RawObject* raw = Object::Allocate(DeoptInfo::kInstanceKind, 6893 RawObject* raw = Object::Allocate(DeoptInfo::kClassId,
7119 size, 6894 size,
7120 Heap::kOld); 6895 Heap::kOld);
7121 NoGCScope no_gc; 6896 NoGCScope no_gc;
7122 result ^= raw; 6897 result ^= raw;
7123 result.SetLength(num_commands); 6898 result.SetLength(num_commands);
7124 } 6899 }
7125 return result.raw(); 6900 return result.raw();
7126 } 6901 }
7127 6902
7128 6903
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
7221 RawCode* Code::New(intptr_t pointer_offsets_length) { 6996 RawCode* Code::New(intptr_t pointer_offsets_length) {
7222 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { 6997 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) {
7223 // This should be caught before we reach here. 6998 // This should be caught before we reach here.
7224 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %ld\n", 6999 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %ld\n",
7225 pointer_offsets_length); 7000 pointer_offsets_length);
7226 } 7001 }
7227 ASSERT(Object::code_class() != Class::null()); 7002 ASSERT(Object::code_class() != Class::null());
7228 Code& result = Code::Handle(); 7003 Code& result = Code::Handle();
7229 { 7004 {
7230 uword size = Code::InstanceSize(pointer_offsets_length); 7005 uword size = Code::InstanceSize(pointer_offsets_length);
7231 RawObject* raw = Object::Allocate(Code::kInstanceKind, size, Heap::kOld); 7006 RawObject* raw = Object::Allocate(Code::kClassId, size, Heap::kOld);
7232 NoGCScope no_gc; 7007 NoGCScope no_gc;
7233 result ^= raw; 7008 result ^= raw;
7234 result.set_pointer_offsets_length(pointer_offsets_length); 7009 result.set_pointer_offsets_length(pointer_offsets_length);
7235 result.set_is_optimized(false); 7010 result.set_is_optimized(false);
7236 result.set_comments(Comments::New(0)); 7011 result.set_comments(Comments::New(0));
7237 } 7012 }
7238 return result.raw(); 7013 return result.raw();
7239 } 7014 }
7240 7015
7241 7016
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
7459 ASSERT(num_variables >= 0); 7234 ASSERT(num_variables >= 0);
7460 ASSERT(Object::context_class() != Class::null()); 7235 ASSERT(Object::context_class() != Class::null());
7461 7236
7462 if (num_variables < 0 || num_variables > kMaxElements) { 7237 if (num_variables < 0 || num_variables > kMaxElements) {
7463 // This should be caught before we reach here. 7238 // This should be caught before we reach here.
7464 FATAL1("Fatal error in Context::New: invalid num_variables %ld\n", 7239 FATAL1("Fatal error in Context::New: invalid num_variables %ld\n",
7465 num_variables); 7240 num_variables);
7466 } 7241 }
7467 Context& result = Context::Handle(); 7242 Context& result = Context::Handle();
7468 { 7243 {
7469 RawObject* raw = Object::Allocate(Context::kInstanceKind, 7244 RawObject* raw = Object::Allocate(Context::kClassId,
7470 Context::InstanceSize(num_variables), 7245 Context::InstanceSize(num_variables),
7471 space); 7246 space);
7472 NoGCScope no_gc; 7247 NoGCScope no_gc;
7473 result ^= raw; 7248 result ^= raw;
7474 result.set_num_variables(num_variables); 7249 result.set_num_variables(num_variables);
7475 } 7250 }
7476 result.set_isolate(Isolate::Current()); 7251 result.set_isolate(Isolate::Current());
7477 return result.raw(); 7252 return result.raw();
7478 } 7253 }
7479 7254
7480 7255
7481 const char* Context::ToCString() const { 7256 const char* Context::ToCString() const {
7482 return "Context"; 7257 return "Context";
7483 } 7258 }
7484 7259
7485 7260
7486 RawContextScope* ContextScope::New(intptr_t num_variables) { 7261 RawContextScope* ContextScope::New(intptr_t num_variables) {
7487 ASSERT(Object::context_scope_class() != Class::null()); 7262 ASSERT(Object::context_scope_class() != Class::null());
7488 if (num_variables < 0 || num_variables > kMaxElements) { 7263 if (num_variables < 0 || num_variables > kMaxElements) {
7489 // This should be caught before we reach here. 7264 // This should be caught before we reach here.
7490 FATAL1("Fatal error in ContextScope::New: invalid num_variables %ld\n", 7265 FATAL1("Fatal error in ContextScope::New: invalid num_variables %ld\n",
7491 num_variables); 7266 num_variables);
7492 } 7267 }
7493 intptr_t size = ContextScope::InstanceSize(num_variables); 7268 intptr_t size = ContextScope::InstanceSize(num_variables);
7494 ContextScope& result = ContextScope::Handle(); 7269 ContextScope& result = ContextScope::Handle();
7495 { 7270 {
7496 RawObject* raw = Object::Allocate(ContextScope::kInstanceKind, 7271 RawObject* raw = Object::Allocate(ContextScope::kClassId,
7497 size, 7272 size,
7498 Heap::kOld); 7273 Heap::kOld);
7499 NoGCScope no_gc; 7274 NoGCScope no_gc;
7500 result ^= raw; 7275 result ^= raw;
7501 result.set_num_variables(num_variables); 7276 result.set_num_variables(num_variables);
7502 } 7277 }
7503 return result.raw(); 7278 return result.raw();
7504 } 7279 }
7505 7280
7506 7281
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
7613 } 7388 }
7614 7389
7615 7390
7616 intptr_t ICData::NumberOfChecks() const { 7391 intptr_t ICData::NumberOfChecks() const {
7617 // Do not count the sentinel; 7392 // Do not count the sentinel;
7618 return (Array::Handle(ic_data()).Length() / TestEntryLength()) - 1; 7393 return (Array::Handle(ic_data()).Length() / TestEntryLength()) - 1;
7619 } 7394 }
7620 7395
7621 7396
7622 void ICData::WriteSentinel() const { 7397 void ICData::WriteSentinel() const {
7623 const Smi& sentinel_value = Smi::Handle(Smi::New(kIllegalObjectKind)); 7398 const Smi& sentinel_value = Smi::Handle(Smi::New(kIllegalCid));
7624 const Array& data = Array::Handle(ic_data()); 7399 const Array& data = Array::Handle(ic_data());
7625 for (intptr_t i = 1; i <= TestEntryLength(); i++) { 7400 for (intptr_t i = 1; i <= TestEntryLength(); i++) {
7626 data.SetAt(data.Length() - i, sentinel_value); 7401 data.SetAt(data.Length() - i, sentinel_value);
7627 } 7402 }
7628 } 7403 }
7629 7404
7630 7405
7631 void ICData::AddCheck(const GrowableArray<intptr_t>& class_ids, 7406 void ICData::AddCheck(const GrowableArray<intptr_t>& class_ids,
7632 const Function& target) const { 7407 const Function& target) const {
7633 ASSERT(num_args_tested() > 1); // Otherwise use 'AddReceiverCheck'. 7408 ASSERT(num_args_tested() > 1); // Otherwise use 'AddReceiverCheck'.
7634 ASSERT(class_ids.length() == num_args_tested()); 7409 ASSERT(class_ids.length() == num_args_tested());
7635 const intptr_t old_num = NumberOfChecks(); 7410 const intptr_t old_num = NumberOfChecks();
7636 Array& data = Array::Handle(ic_data()); 7411 Array& data = Array::Handle(ic_data());
7637 const intptr_t new_len = data.Length() + TestEntryLength(); 7412 const intptr_t new_len = data.Length() + TestEntryLength();
7638 data = Array::Grow(data, new_len, Heap::kOld); 7413 data = Array::Grow(data, new_len, Heap::kOld);
7639 set_ic_data(data); 7414 set_ic_data(data);
7640 WriteSentinel(); 7415 WriteSentinel();
7641 intptr_t data_pos = old_num * TestEntryLength(); 7416 intptr_t data_pos = old_num * TestEntryLength();
7642 for (intptr_t i = 0; i < class_ids.length(); i++) { 7417 for (intptr_t i = 0; i < class_ids.length(); i++) {
7643 // kIllegalObjectKind is used as terminating value, do not add it. 7418 // kIllegalCid is used as terminating value, do not add it.
7644 ASSERT(class_ids[i] != kIllegalObjectKind); 7419 ASSERT(class_ids[i] != kIllegalCid);
7645 data.SetAt(data_pos++, Smi::Handle(Smi::New(class_ids[i]))); 7420 data.SetAt(data_pos++, Smi::Handle(Smi::New(class_ids[i])));
7646 } 7421 }
7647 ASSERT(!target.IsNull()); 7422 ASSERT(!target.IsNull());
7648 data.SetAt(data_pos, target); 7423 data.SetAt(data_pos, target);
7649 } 7424 }
7650 7425
7651 7426
7652 void ICData::AddReceiverCheck(intptr_t receiver_class_id, 7427 void ICData::AddReceiverCheck(intptr_t receiver_class_id,
7653 const Function& target) const { 7428 const Function& target) const {
7654 ASSERT(num_args_tested() == 1); // Otherwise use 'AddCheck'. 7429 ASSERT(num_args_tested() == 1); // Otherwise use 'AddCheck'.
7655 ASSERT(receiver_class_id != kIllegalObjectKind); 7430 ASSERT(receiver_class_id != kIllegalCid);
7656 ASSERT(!target.IsNull()); 7431 ASSERT(!target.IsNull());
7657 7432
7658 const intptr_t old_num = NumberOfChecks(); 7433 const intptr_t old_num = NumberOfChecks();
7659 Array& data = Array::Handle(ic_data()); 7434 Array& data = Array::Handle(ic_data());
7660 const intptr_t new_len = data.Length() + TestEntryLength(); 7435 const intptr_t new_len = data.Length() + TestEntryLength();
7661 data = Array::Grow(data, new_len, Heap::kOld); 7436 data = Array::Grow(data, new_len, Heap::kOld);
7662 set_ic_data(data); 7437 set_ic_data(data);
7663 WriteSentinel(); 7438 WriteSentinel();
7664 intptr_t data_pos = old_num * TestEntryLength(); 7439 intptr_t data_pos = old_num * TestEntryLength();
7665 if ((receiver_class_id == kSmi) && (data_pos > 0)) { 7440 if ((receiver_class_id == kSmiCid) && (data_pos > 0)) {
7666 // Instert kSmi in position 0. 7441 // Instert kSmiCid in position 0.
7667 const intptr_t zero_class_id = GetReceiverClassIdAt(0); 7442 const intptr_t zero_class_id = GetReceiverClassIdAt(0);
7668 ASSERT(zero_class_id != kSmi); // Simple duplicate entry check. 7443 ASSERT(zero_class_id != kSmiCid); // Simple duplicate entry check.
7669 const Function& zero_target = Function::Handle(GetTargetAt(0)); 7444 const Function& zero_target = Function::Handle(GetTargetAt(0));
7670 data.SetAt(0, Smi::Handle(Smi::New(receiver_class_id))); 7445 data.SetAt(0, Smi::Handle(Smi::New(receiver_class_id)));
7671 data.SetAt(1, target); 7446 data.SetAt(1, target);
7672 data.SetAt(data_pos, Smi::Handle(Smi::New(zero_class_id))); 7447 data.SetAt(data_pos, Smi::Handle(Smi::New(zero_class_id)));
7673 data.SetAt(data_pos + 1, zero_target); 7448 data.SetAt(data_pos + 1, zero_target);
7674 } else { 7449 } else {
7675 data.SetAt(data_pos, Smi::Handle(Smi::New(receiver_class_id))); 7450 data.SetAt(data_pos, Smi::Handle(Smi::New(receiver_class_id)));
7676 data.SetAt(data_pos + 1, target); 7451 data.SetAt(data_pos + 1, target);
7677 } 7452 }
7678 } 7453 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
7771 7546
7772 RawICData* ICData::New(const Function& function, 7547 RawICData* ICData::New(const Function& function,
7773 const String& target_name, 7548 const String& target_name,
7774 intptr_t deopt_id, 7549 intptr_t deopt_id,
7775 intptr_t num_args_tested) { 7550 intptr_t num_args_tested) {
7776 ASSERT(Object::icdata_class() != Class::null()); 7551 ASSERT(Object::icdata_class() != Class::null());
7777 ASSERT(num_args_tested > 0); 7552 ASSERT(num_args_tested > 0);
7778 ICData& result = ICData::Handle(); 7553 ICData& result = ICData::Handle();
7779 { 7554 {
7780 // IC data objects are long living objects, allocate them in old generation. 7555 // IC data objects are long living objects, allocate them in old generation.
7781 RawObject* raw = Object::Allocate(ICData::kInstanceKind, 7556 RawObject* raw = Object::Allocate(ICData::kClassId,
7782 ICData::InstanceSize(), 7557 ICData::InstanceSize(),
7783 Heap::kOld); 7558 Heap::kOld);
7784 NoGCScope no_gc; 7559 NoGCScope no_gc;
7785 result ^= raw; 7560 result ^= raw;
7786 } 7561 }
7787 result.set_function(function); 7562 result.set_function(function);
7788 result.set_target_name(target_name); 7563 result.set_target_name(target_name);
7789 result.set_deopt_id(deopt_id); 7564 result.set_deopt_id(deopt_id);
7790 result.set_num_args_tested(num_args_tested); 7565 result.set_num_args_tested(num_args_tested);
7791 // Number of array elements in one test entry (num_args_tested + 1) 7566 // Number of array elements in one test entry (num_args_tested + 1)
7792 intptr_t len = result.TestEntryLength(); 7567 intptr_t len = result.TestEntryLength();
7793 // IC data array must be null terminated (sentinel entry). 7568 // IC data array must be null terminated (sentinel entry).
7794 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); 7569 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld));
7795 result.set_ic_data(ic_data); 7570 result.set_ic_data(ic_data);
7796 result.WriteSentinel(); 7571 result.WriteSentinel();
7797 return result.raw(); 7572 return result.raw();
7798 } 7573 }
7799 7574
7800 7575
7801 RawSubtypeTestCache* SubtypeTestCache::New() { 7576 RawSubtypeTestCache* SubtypeTestCache::New() {
7802 ASSERT(Object::subtypetestcache_class() != Class::null()); 7577 ASSERT(Object::subtypetestcache_class() != Class::null());
7803 SubtypeTestCache& result = SubtypeTestCache::Handle(); 7578 SubtypeTestCache& result = SubtypeTestCache::Handle();
7804 { 7579 {
7805 // SubtypeTestCache objects are long living objects, allocate them in the 7580 // SubtypeTestCache objects are long living objects, allocate them in the
7806 // old generation. 7581 // old generation.
7807 RawObject* raw = Object::Allocate(SubtypeTestCache::kInstanceKind, 7582 RawObject* raw = Object::Allocate(SubtypeTestCache::kClassId,
7808 SubtypeTestCache::InstanceSize(), 7583 SubtypeTestCache::InstanceSize(),
7809 Heap::kOld); 7584 Heap::kOld);
7810 NoGCScope no_gc; 7585 NoGCScope no_gc;
7811 result ^= raw; 7586 result ^= raw;
7812 } 7587 }
7813 const Array& cache = Array::Handle(Array::New(kTestEntryLength)); 7588 const Array& cache = Array::Handle(Array::New(kTestEntryLength));
7814 result.set_cache(cache); 7589 result.set_cache(cache);
7815 return result.raw(); 7590 return result.raw();
7816 } 7591 }
7817 7592
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
7880 // Error is an abstract class. We should never reach here. 7655 // Error is an abstract class. We should never reach here.
7881 UNREACHABLE(); 7656 UNREACHABLE();
7882 return "Error"; 7657 return "Error";
7883 } 7658 }
7884 7659
7885 7660
7886 RawApiError* ApiError::New(const String& message, Heap::Space space) { 7661 RawApiError* ApiError::New(const String& message, Heap::Space space) {
7887 ASSERT(Object::api_error_class() != Class::null()); 7662 ASSERT(Object::api_error_class() != Class::null());
7888 ApiError& result = ApiError::Handle(); 7663 ApiError& result = ApiError::Handle();
7889 { 7664 {
7890 RawObject* raw = Object::Allocate(ApiError::kInstanceKind, 7665 RawObject* raw = Object::Allocate(ApiError::kClassId,
7891 ApiError::InstanceSize(), 7666 ApiError::InstanceSize(),
7892 space); 7667 space);
7893 NoGCScope no_gc; 7668 NoGCScope no_gc;
7894 result ^= raw; 7669 result ^= raw;
7895 } 7670 }
7896 result.set_message(message); 7671 result.set_message(message);
7897 return result.raw(); 7672 return result.raw();
7898 } 7673 }
7899 7674
7900 7675
(...skipping 10 matching lines...) Expand all
7911 7686
7912 const char* ApiError::ToCString() const { 7687 const char* ApiError::ToCString() const {
7913 return "ApiError"; 7688 return "ApiError";
7914 } 7689 }
7915 7690
7916 7691
7917 RawLanguageError* LanguageError::New(const String& message, Heap::Space space) { 7692 RawLanguageError* LanguageError::New(const String& message, Heap::Space space) {
7918 ASSERT(Object::language_error_class() != Class::null()); 7693 ASSERT(Object::language_error_class() != Class::null());
7919 LanguageError& result = LanguageError::Handle(); 7694 LanguageError& result = LanguageError::Handle();
7920 { 7695 {
7921 RawObject* raw = Object::Allocate(LanguageError::kInstanceKind, 7696 RawObject* raw = Object::Allocate(LanguageError::kClassId,
7922 LanguageError::InstanceSize(), 7697 LanguageError::InstanceSize(),
7923 space); 7698 space);
7924 NoGCScope no_gc; 7699 NoGCScope no_gc;
7925 result ^= raw; 7700 result ^= raw;
7926 } 7701 }
7927 result.set_message(message); 7702 result.set_message(message);
7928 return result.raw(); 7703 return result.raw();
7929 } 7704 }
7930 7705
7931 7706
(...skipping 12 matching lines...) Expand all
7944 return "LanguageError"; 7719 return "LanguageError";
7945 } 7720 }
7946 7721
7947 7722
7948 RawUnhandledException* UnhandledException::New(const Instance& exception, 7723 RawUnhandledException* UnhandledException::New(const Instance& exception,
7949 const Instance& stacktrace, 7724 const Instance& stacktrace,
7950 Heap::Space space) { 7725 Heap::Space space) {
7951 ASSERT(Object::unhandled_exception_class() != Class::null()); 7726 ASSERT(Object::unhandled_exception_class() != Class::null());
7952 UnhandledException& result = UnhandledException::Handle(); 7727 UnhandledException& result = UnhandledException::Handle();
7953 { 7728 {
7954 RawObject* raw = Object::Allocate(UnhandledException::kInstanceKind, 7729 RawObject* raw = Object::Allocate(UnhandledException::kClassId,
7955 UnhandledException::InstanceSize(), 7730 UnhandledException::InstanceSize(),
7956 space); 7731 space);
7957 NoGCScope no_gc; 7732 NoGCScope no_gc;
7958 result ^= raw; 7733 result ^= raw;
7959 } 7734 }
7960 result.set_exception(exception); 7735 result.set_exception(exception);
7961 result.set_stacktrace(stacktrace); 7736 result.set_stacktrace(stacktrace);
7962 return result.raw(); 7737 return result.raw();
7963 } 7738 }
7964 7739
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
8005 7780
8006 const char* UnhandledException::ToCString() const { 7781 const char* UnhandledException::ToCString() const {
8007 return "UnhandledException"; 7782 return "UnhandledException";
8008 } 7783 }
8009 7784
8010 7785
8011 RawUnwindError* UnwindError::New(const String& message, Heap::Space space) { 7786 RawUnwindError* UnwindError::New(const String& message, Heap::Space space) {
8012 ASSERT(Object::unwind_error_class() != Class::null()); 7787 ASSERT(Object::unwind_error_class() != Class::null());
8013 UnwindError& result = UnwindError::Handle(); 7788 UnwindError& result = UnwindError::Handle();
8014 { 7789 {
8015 RawObject* raw = Object::Allocate(UnwindError::kInstanceKind, 7790 RawObject* raw = Object::Allocate(UnwindError::kClassId,
8016 UnwindError::InstanceSize(), 7791 UnwindError::InstanceSize(),
8017 space); 7792 space);
8018 NoGCScope no_gc; 7793 NoGCScope no_gc;
8019 result ^= raw; 7794 result ^= raw;
8020 } 7795 }
8021 result.set_message(message); 7796 result.set_message(message);
8022 return result.raw(); 7797 return result.raw();
8023 } 7798 }
8024 7799
8025 7800
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
8420 raw_ptr()->value_ = value; 8195 raw_ptr()->value_ = value;
8421 } 8196 }
8422 8197
8423 8198
8424 RawMint* Mint::New(int64_t val, Heap::Space space) { 8199 RawMint* Mint::New(int64_t val, Heap::Space space) {
8425 // Do not allocate a Mint if Smi would do. 8200 // Do not allocate a Mint if Smi would do.
8426 ASSERT(!Smi::IsValid64(val)); 8201 ASSERT(!Smi::IsValid64(val));
8427 ASSERT(Isolate::Current()->object_store()->mint_class() != Class::null()); 8202 ASSERT(Isolate::Current()->object_store()->mint_class() != Class::null());
8428 Mint& result = Mint::Handle(); 8203 Mint& result = Mint::Handle();
8429 { 8204 {
8430 RawObject* raw = Object::Allocate(Mint::kInstanceKind, 8205 RawObject* raw = Object::Allocate(Mint::kClassId,
8431 Mint::InstanceSize(), 8206 Mint::InstanceSize(),
8432 space); 8207 space);
8433 NoGCScope no_gc; 8208 NoGCScope no_gc;
8434 result ^= raw; 8209 result ^= raw;
8435 } 8210 }
8436 result.set_value(val); 8211 result.set_value(val);
8437 return result.raw(); 8212 return result.raw();
8438 } 8213 }
8439 8214
8440 8215
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
8547 return false; 8322 return false;
8548 } 8323 }
8549 return EqualsToDouble(Double::Cast(other).value()); 8324 return EqualsToDouble(Double::Cast(other).value());
8550 } 8325 }
8551 8326
8552 8327
8553 RawDouble* Double::New(double d, Heap::Space space) { 8328 RawDouble* Double::New(double d, Heap::Space space) {
8554 ASSERT(Isolate::Current()->object_store()->double_class() != Class::null()); 8329 ASSERT(Isolate::Current()->object_store()->double_class() != Class::null());
8555 Double& result = Double::Handle(); 8330 Double& result = Double::Handle();
8556 { 8331 {
8557 RawObject* raw = Object::Allocate(Double::kInstanceKind, 8332 RawObject* raw = Object::Allocate(Double::kClassId,
8558 Double::InstanceSize(), 8333 Double::InstanceSize(),
8559 space); 8334 space);
8560 NoGCScope no_gc; 8335 NoGCScope no_gc;
8561 result ^= raw; 8336 result ^= raw;
8562 } 8337 }
8563 result.set_value(d); 8338 result.set_value(d);
8564 return result.raw(); 8339 return result.raw();
8565 } 8340 }
8566 8341
8567 8342
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
8710 8485
8711 8486
8712 RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) { 8487 RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) {
8713 if (length < 0 || length > kMaxElements) { 8488 if (length < 0 || length > kMaxElements) {
8714 // This should be caught before we reach here. 8489 // This should be caught before we reach here.
8715 FATAL1("Fatal error in Bigint::Allocate: invalid length %ld\n", length); 8490 FATAL1("Fatal error in Bigint::Allocate: invalid length %ld\n", length);
8716 } 8491 }
8717 ASSERT(Isolate::Current()->object_store()->bigint_class() != Class::null()); 8492 ASSERT(Isolate::Current()->object_store()->bigint_class() != Class::null());
8718 Bigint& result = Bigint::Handle(); 8493 Bigint& result = Bigint::Handle();
8719 { 8494 {
8720 RawObject* raw = Object::Allocate(Bigint::kInstanceKind, 8495 RawObject* raw = Object::Allocate(Bigint::kClassId,
8721 Bigint::InstanceSize(length), 8496 Bigint::InstanceSize(length),
8722 space); 8497 space);
8723 NoGCScope no_gc; 8498 NoGCScope no_gc;
8724 result ^= raw; 8499 result ^= raw;
8725 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated. 8500 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated.
8726 result.raw_ptr()->signed_length_ = length; // Chunk length in use. 8501 result.raw_ptr()->signed_length_ = length; // Chunk length in use.
8727 } 8502 }
8728 return result.raw(); 8503 return result.raw();
8729 } 8504 }
8730 8505
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
9473 Heap::Space space) { 9248 Heap::Space space) {
9474 ASSERT(Isolate::Current() == Dart::vm_isolate() || 9249 ASSERT(Isolate::Current() == Dart::vm_isolate() ||
9475 Isolate::Current()->object_store()->one_byte_string_class() != 9250 Isolate::Current()->object_store()->one_byte_string_class() !=
9476 Class::null()); 9251 Class::null());
9477 if (len < 0 || len > kMaxElements) { 9252 if (len < 0 || len > kMaxElements) {
9478 // This should be caught before we reach here. 9253 // This should be caught before we reach here.
9479 FATAL1("Fatal error in OneByteString::New: invalid len %ld\n", len); 9254 FATAL1("Fatal error in OneByteString::New: invalid len %ld\n", len);
9480 } 9255 }
9481 OneByteString& result = OneByteString::Handle(); 9256 OneByteString& result = OneByteString::Handle();
9482 { 9257 {
9483 RawObject* raw = Object::Allocate(OneByteString::kInstanceKind, 9258 RawObject* raw = Object::Allocate(OneByteString::kClassId,
9484 OneByteString::InstanceSize(len), 9259 OneByteString::InstanceSize(len),
9485 space); 9260 space);
9486 NoGCScope no_gc; 9261 NoGCScope no_gc;
9487 result ^= raw; 9262 result ^= raw;
9488 result.SetLength(len); 9263 result.SetLength(len);
9489 result.SetHash(0); 9264 result.SetHash(0);
9490 } 9265 }
9491 return result.raw(); 9266 return result.raw();
9492 } 9267 }
9493 9268
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
9615 9390
9616 RawTwoByteString* TwoByteString::New(intptr_t len, 9391 RawTwoByteString* TwoByteString::New(intptr_t len,
9617 Heap::Space space) { 9392 Heap::Space space) {
9618 ASSERT(Isolate::Current()->object_store()->two_byte_string_class()); 9393 ASSERT(Isolate::Current()->object_store()->two_byte_string_class());
9619 if (len < 0 || len > kMaxElements) { 9394 if (len < 0 || len > kMaxElements) {
9620 // This should be caught before we reach here. 9395 // This should be caught before we reach here.
9621 FATAL1("Fatal error in TwoByteString::New: invalid len %ld\n", len); 9396 FATAL1("Fatal error in TwoByteString::New: invalid len %ld\n", len);
9622 } 9397 }
9623 TwoByteString& result = TwoByteString::Handle(); 9398 TwoByteString& result = TwoByteString::Handle();
9624 { 9399 {
9625 RawObject* raw = Object::Allocate(TwoByteString::kInstanceKind, 9400 RawObject* raw = Object::Allocate(TwoByteString::kClassId,
9626 TwoByteString::InstanceSize(len), 9401 TwoByteString::InstanceSize(len),
9627 space); 9402 space);
9628 NoGCScope no_gc; 9403 NoGCScope no_gc;
9629 result ^= raw; 9404 result ^= raw;
9630 result.SetLength(len); 9405 result.SetLength(len);
9631 result.SetHash(0); 9406 result.SetHash(0);
9632 } 9407 }
9633 return result.raw(); 9408 return result.raw();
9634 } 9409 }
9635 9410
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
9748 RawFourByteString* FourByteString::New(intptr_t len, 9523 RawFourByteString* FourByteString::New(intptr_t len,
9749 Heap::Space space) { 9524 Heap::Space space) {
9750 ASSERT(Isolate::Current()->object_store()->four_byte_string_class() != 9525 ASSERT(Isolate::Current()->object_store()->four_byte_string_class() !=
9751 Class::null()); 9526 Class::null());
9752 if (len < 0 || len > kMaxElements) { 9527 if (len < 0 || len > kMaxElements) {
9753 // This should be caught before we reach here. 9528 // This should be caught before we reach here.
9754 FATAL1("Fatal error in FourByteString::New: invalid len %ld\n", len); 9529 FATAL1("Fatal error in FourByteString::New: invalid len %ld\n", len);
9755 } 9530 }
9756 FourByteString& result = FourByteString::Handle(); 9531 FourByteString& result = FourByteString::Handle();
9757 { 9532 {
9758 RawObject* raw = Object::Allocate(FourByteString::kInstanceKind, 9533 RawObject* raw = Object::Allocate(FourByteString::kClassId,
9759 FourByteString::InstanceSize(len), 9534 FourByteString::InstanceSize(len),
9760 space); 9535 space);
9761 NoGCScope no_gc; 9536 NoGCScope no_gc;
9762 result ^= raw; 9537 result ^= raw;
9763 result.SetLength(len); 9538 result.SetLength(len);
9764 result.SetHash(0); 9539 result.SetHash(0);
9765 } 9540 }
9766 return result.raw(); 9541 return result.raw();
9767 } 9542 }
9768 9543
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
9861 ASSERT(Isolate::Current()->object_store()->external_one_byte_string_class() != 9636 ASSERT(Isolate::Current()->object_store()->external_one_byte_string_class() !=
9862 Class::null()); 9637 Class::null());
9863 if (len < 0 || len > kMaxElements) { 9638 if (len < 0 || len > kMaxElements) {
9864 // This should be caught before we reach here. 9639 // This should be caught before we reach here.
9865 FATAL1("Fatal error in ExternalOneByteString::New: invalid len %ld\n", len); 9640 FATAL1("Fatal error in ExternalOneByteString::New: invalid len %ld\n", len);
9866 } 9641 }
9867 ExternalOneByteString& result = ExternalOneByteString::Handle(); 9642 ExternalOneByteString& result = ExternalOneByteString::Handle();
9868 ExternalStringData<uint8_t>* external_data = 9643 ExternalStringData<uint8_t>* external_data =
9869 new ExternalStringData<uint8_t>(data, peer, callback); 9644 new ExternalStringData<uint8_t>(data, peer, callback);
9870 { 9645 {
9871 RawObject* raw = Object::Allocate(ExternalOneByteString::kInstanceKind, 9646 RawObject* raw = Object::Allocate(ExternalOneByteString::kClassId,
9872 ExternalOneByteString::InstanceSize(), 9647 ExternalOneByteString::InstanceSize(),
9873 space); 9648 space);
9874 NoGCScope no_gc; 9649 NoGCScope no_gc;
9875 result ^= raw; 9650 result ^= raw;
9876 result.SetLength(len); 9651 result.SetLength(len);
9877 result.SetHash(0); 9652 result.SetHash(0);
9878 result.SetExternalData(external_data); 9653 result.SetExternalData(external_data);
9879 } 9654 }
9880 AddFinalizer(result, external_data, ExternalOneByteString::Finalize); 9655 AddFinalizer(result, external_data, ExternalOneByteString::Finalize);
9881 return result.raw(); 9656 return result.raw();
(...skipping 30 matching lines...) Expand all
9912 ASSERT(Isolate::Current()->object_store()->external_two_byte_string_class() != 9687 ASSERT(Isolate::Current()->object_store()->external_two_byte_string_class() !=
9913 Class::null()); 9688 Class::null());
9914 if (len < 0 || len > kMaxElements) { 9689 if (len < 0 || len > kMaxElements) {
9915 // This should be caught before we reach here. 9690 // This should be caught before we reach here.
9916 FATAL1("Fatal error in ExternalTwoByteString::New: invalid len %ld\n", len); 9691 FATAL1("Fatal error in ExternalTwoByteString::New: invalid len %ld\n", len);
9917 } 9692 }
9918 ExternalTwoByteString& result = ExternalTwoByteString::Handle(); 9693 ExternalTwoByteString& result = ExternalTwoByteString::Handle();
9919 ExternalStringData<uint16_t>* external_data = 9694 ExternalStringData<uint16_t>* external_data =
9920 new ExternalStringData<uint16_t>(data, peer, callback); 9695 new ExternalStringData<uint16_t>(data, peer, callback);
9921 { 9696 {
9922 RawObject* raw = Object::Allocate(ExternalTwoByteString::kInstanceKind, 9697 RawObject* raw = Object::Allocate(ExternalTwoByteString::kClassId,
9923 ExternalTwoByteString::InstanceSize(), 9698 ExternalTwoByteString::InstanceSize(),
9924 space); 9699 space);
9925 NoGCScope no_gc; 9700 NoGCScope no_gc;
9926 result ^= raw; 9701 result ^= raw;
9927 result.SetLength(len); 9702 result.SetLength(len);
9928 result.SetHash(0); 9703 result.SetHash(0);
9929 result.SetExternalData(external_data); 9704 result.SetExternalData(external_data);
9930 } 9705 }
9931 AddFinalizer(result, external_data, ExternalTwoByteString::Finalize); 9706 AddFinalizer(result, external_data, ExternalTwoByteString::Finalize);
9932 return result.raw(); 9707 return result.raw();
(...skipping 21 matching lines...) Expand all
9954 external_four_byte_string_class() != Class::null()); 9729 external_four_byte_string_class() != Class::null());
9955 if (len < 0 || len > kMaxElements) { 9730 if (len < 0 || len > kMaxElements) {
9956 // This should be caught before we reach here. 9731 // This should be caught before we reach here.
9957 FATAL1("Fatal error in ExternalFourByteString::New: invalid len %ld\n", 9732 FATAL1("Fatal error in ExternalFourByteString::New: invalid len %ld\n",
9958 len); 9733 len);
9959 } 9734 }
9960 ExternalFourByteString& result = ExternalFourByteString::Handle(); 9735 ExternalFourByteString& result = ExternalFourByteString::Handle();
9961 ExternalStringData<uint32_t>* external_data = 9736 ExternalStringData<uint32_t>* external_data =
9962 new ExternalStringData<uint32_t>(data, peer, callback); 9737 new ExternalStringData<uint32_t>(data, peer, callback);
9963 { 9738 {
9964 RawObject* raw = Object::Allocate(ExternalFourByteString::kInstanceKind, 9739 RawObject* raw = Object::Allocate(ExternalFourByteString::kClassId,
9965 ExternalFourByteString::InstanceSize(), 9740 ExternalFourByteString::InstanceSize(),
9966 space); 9741 space);
9967 NoGCScope no_gc; 9742 NoGCScope no_gc;
9968 result ^= raw; 9743 result ^= raw;
9969 result.SetLength(len); 9744 result.SetLength(len);
9970 result.SetHash(0); 9745 result.SetHash(0);
9971 result.SetExternalData(external_data); 9746 result.SetExternalData(external_data);
9972 } 9747 }
9973 AddFinalizer(result, external_data, ExternalFourByteString::Finalize); 9748 AddFinalizer(result, external_data, ExternalFourByteString::Finalize);
9974 return result.raw(); 9749 return result.raw();
(...skipping 20 matching lines...) Expand all
9995 return Isolate::Current()->object_store()->false_value(); 9770 return Isolate::Current()->object_store()->false_value();
9996 } 9771 }
9997 9772
9998 9773
9999 RawBool* Bool::New(bool value) { 9774 RawBool* Bool::New(bool value) {
10000 ASSERT(Isolate::Current()->object_store()->bool_class() != Class::null()); 9775 ASSERT(Isolate::Current()->object_store()->bool_class() != Class::null());
10001 Bool& result = Bool::Handle(); 9776 Bool& result = Bool::Handle();
10002 { 9777 {
10003 // Since the two boolean instances are singletons we allocate them straight 9778 // Since the two boolean instances are singletons we allocate them straight
10004 // in the old generation. 9779 // in the old generation.
10005 RawObject* raw = Object::Allocate(Bool::kInstanceKind, 9780 RawObject* raw = Object::Allocate(Bool::kClassId,
10006 Bool::InstanceSize(), 9781 Bool::InstanceSize(),
10007 Heap::kOld); 9782 Heap::kOld);
10008 NoGCScope no_gc; 9783 NoGCScope no_gc;
10009 result ^= raw; 9784 result ^= raw;
10010 } 9785 }
10011 result.set_value(value); 9786 result.set_value(value);
10012 return result.raw(); 9787 return result.raw();
10013 } 9788 }
10014 9789
10015 9790
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
10124 intptr_t capacity_len = growable_array.Capacity(); 9899 intptr_t capacity_len = growable_array.Capacity();
10125 Isolate* isolate = Isolate::Current(); 9900 Isolate* isolate = Isolate::Current();
10126 const Array& array = Array::Handle(isolate, growable_array.data()); 9901 const Array& array = Array::Handle(isolate, growable_array.data());
10127 const Array& new_array = Array::Handle(isolate, Array::Empty()); 9902 const Array& new_array = Array::Handle(isolate, Array::Empty());
10128 intptr_t capacity_size = Array::InstanceSize(capacity_len); 9903 intptr_t capacity_size = Array::InstanceSize(capacity_len);
10129 intptr_t used_size = Array::InstanceSize(used_len); 9904 intptr_t used_size = Array::InstanceSize(used_len);
10130 NoGCScope no_gc; 9905 NoGCScope no_gc;
10131 9906
10132 // Update the size in the header field and length of the array object. 9907 // Update the size in the header field and length of the array object.
10133 uword tags = array.raw_ptr()->tags_; 9908 uword tags = array.raw_ptr()->tags_;
10134 ASSERT(kArray == RawObject::ClassIdTag::decode(tags)); 9909 ASSERT(kArrayCid == RawObject::ClassIdTag::decode(tags));
10135 tags = RawObject::SizeTag::update(used_size, tags); 9910 tags = RawObject::SizeTag::update(used_size, tags);
10136 array.raw_ptr()->tags_ = tags; 9911 array.raw_ptr()->tags_ = tags;
10137 array.SetLength(used_len); 9912 array.SetLength(used_len);
10138 9913
10139 // Null the GrowableObjectArray, we are removing it's backing array. 9914 // Null the GrowableObjectArray, we are removing it's backing array.
10140 growable_array.SetLength(0); 9915 growable_array.SetLength(0);
10141 growable_array.SetData(new_array); 9916 growable_array.SetData(new_array);
10142 9917
10143 // If there is any left over space fill it with either an Array object or 9918 // If there is any left over space fill it with either an Array object or
10144 // just a plain object (depending on the amount of left over space) so 9919 // just a plain object (depending on the amount of left over space) so
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
10281 return New(data, space); 10056 return New(data, space);
10282 } 10057 }
10283 10058
10284 10059
10285 RawGrowableObjectArray* GrowableObjectArray::New(const Array& array, 10060 RawGrowableObjectArray* GrowableObjectArray::New(const Array& array,
10286 Heap::Space space) { 10061 Heap::Space space) {
10287 ASSERT(Isolate::Current()->object_store()->growable_object_array_class() 10062 ASSERT(Isolate::Current()->object_store()->growable_object_array_class()
10288 != Class::null()); 10063 != Class::null());
10289 GrowableObjectArray& result = GrowableObjectArray::Handle(); 10064 GrowableObjectArray& result = GrowableObjectArray::Handle();
10290 { 10065 {
10291 RawObject* raw = Object::Allocate(GrowableObjectArray::kInstanceKind, 10066 RawObject* raw = Object::Allocate(GrowableObjectArray::kClassId,
10292 GrowableObjectArray::InstanceSize(), 10067 GrowableObjectArray::InstanceSize(),
10293 space); 10068 space);
10294 NoGCScope no_gc; 10069 NoGCScope no_gc;
10295 result ^= raw; 10070 result ^= raw;
10296 result.SetLength(0); 10071 result.SetLength(0);
10297 result.SetData(array); 10072 result.SetData(array);
10298 } 10073 }
10299 return result.raw(); 10074 return result.raw();
10300 } 10075 }
10301 10076
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
10983 10758
10984 10759
10985 RawStacktrace* Stacktrace::New(const GrowableObjectArray& func_list, 10760 RawStacktrace* Stacktrace::New(const GrowableObjectArray& func_list,
10986 const GrowableObjectArray& code_list, 10761 const GrowableObjectArray& code_list,
10987 const GrowableObjectArray& pc_offset_list, 10762 const GrowableObjectArray& pc_offset_list,
10988 Heap::Space space) { 10763 Heap::Space space) {
10989 ASSERT(Isolate::Current()->object_store()->stacktrace_class() != 10764 ASSERT(Isolate::Current()->object_store()->stacktrace_class() !=
10990 Class::null()); 10765 Class::null());
10991 Stacktrace& result = Stacktrace::Handle(); 10766 Stacktrace& result = Stacktrace::Handle();
10992 { 10767 {
10993 RawObject* raw = Object::Allocate(Stacktrace::kInstanceKind, 10768 RawObject* raw = Object::Allocate(Stacktrace::kClassId,
10994 Stacktrace::InstanceSize(), 10769 Stacktrace::InstanceSize(),
10995 space); 10770 space);
10996 NoGCScope no_gc; 10771 NoGCScope no_gc;
10997 result ^= raw; 10772 result ^= raw;
10998 } 10773 }
10999 // Create arrays for the function, code and pc_offset triplet for each frame. 10774 // Create arrays for the function, code and pc_offset triplet for each frame.
11000 const Array& function_array = Array::Handle(Array::MakeArray(func_list)); 10775 const Array& function_array = Array::Handle(Array::MakeArray(func_list));
11001 const Array& code_array = Array::Handle(Array::MakeArray(code_list)); 10776 const Array& code_array = Array::Handle(Array::MakeArray(code_list));
11002 const Array& pc_offset_array = 10777 const Array& pc_offset_array =
11003 Array::Handle(Array::MakeArray(pc_offset_list)); 10778 Array::Handle(Array::MakeArray(pc_offset_list));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
11108 10883
11109 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { 10884 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) {
11110 ASSERT(Isolate::Current()->object_store()->jsregexp_class() != 10885 ASSERT(Isolate::Current()->object_store()->jsregexp_class() !=
11111 Class::null()); 10886 Class::null());
11112 if (len < 0 || len > kMaxElements) { 10887 if (len < 0 || len > kMaxElements) {
11113 // This should be caught before we reach here. 10888 // This should be caught before we reach here.
11114 FATAL1("Fatal error in JSRegexp::New: invalid len %ld\n", len); 10889 FATAL1("Fatal error in JSRegexp::New: invalid len %ld\n", len);
11115 } 10890 }
11116 JSRegExp& result = JSRegExp::Handle(); 10891 JSRegExp& result = JSRegExp::Handle();
11117 { 10892 {
11118 RawObject* raw = Object::Allocate(JSRegExp::kInstanceKind, 10893 RawObject* raw = Object::Allocate(JSRegExp::kClassId,
11119 JSRegExp::InstanceSize(len), 10894 JSRegExp::InstanceSize(len),
11120 space); 10895 space);
11121 NoGCScope no_gc; 10896 NoGCScope no_gc;
11122 result ^= raw; 10897 result ^= raw;
11123 result.set_type(kUnitialized); 10898 result.set_type(kUnitialized);
11124 result.set_flags(0); 10899 result.set_flags(0);
11125 result.SetLength(len); 10900 result.SetLength(len);
11126 } 10901 }
11127 return result.raw(); 10902 return result.raw();
11128 } 10903 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
11187 const char* JSRegExp::ToCString() const { 10962 const char* JSRegExp::ToCString() const {
11188 const String& str = String::Handle(pattern()); 10963 const String& str = String::Handle(pattern());
11189 const char* format = "JSRegExp: pattern=%s flags=%s"; 10964 const char* format = "JSRegExp: pattern=%s flags=%s";
11190 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10965 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
11191 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); 10966 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
11192 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10967 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
11193 return chars; 10968 return chars;
11194 } 10969 }
11195 10970
11196 } // namespace dart 10971 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object.h ('k') | vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698