OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
11 #include "vm/code_generator.h" | 11 #include "vm/code_generator.h" |
12 #include "vm/code_index_table.h" | 12 #include "vm/code_index_table.h" |
13 #include "vm/code_patcher.h" | 13 #include "vm/code_patcher.h" |
14 #include "vm/compiler.h" | 14 #include "vm/compiler.h" |
15 #include "vm/compiler_stats.h" | 15 #include "vm/compiler_stats.h" |
16 #include "vm/class_finalizer.h" | 16 #include "vm/class_finalizer.h" |
17 #include "vm/dart.h" | 17 #include "vm/dart.h" |
18 #include "vm/debuginfo.h" | 18 #include "vm/debuginfo.h" |
| 19 #include "vm/exceptions.h" |
19 #include "vm/growable_array.h" | 20 #include "vm/growable_array.h" |
20 #include "vm/heap.h" | 21 #include "vm/heap.h" |
21 #include "vm/ic_data.h" | 22 #include "vm/ic_data.h" |
22 #include "vm/object_store.h" | 23 #include "vm/object_store.h" |
23 #include "vm/parser.h" | 24 #include "vm/parser.h" |
24 #include "vm/runtime_entry.h" | 25 #include "vm/runtime_entry.h" |
25 #include "vm/scopes.h" | 26 #include "vm/scopes.h" |
26 #include "vm/timer.h" | 27 #include "vm/timer.h" |
27 #include "vm/unicode.h" | 28 #include "vm/unicode.h" |
28 | 29 |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 | 715 |
715 | 716 |
716 RawObject* Object::Allocate(const Class& cls, | 717 RawObject* Object::Allocate(const Class& cls, |
717 intptr_t size, | 718 intptr_t size, |
718 Heap::Space space) { | 719 Heap::Space space) { |
719 Isolate* isolate = Isolate::Current(); | 720 Isolate* isolate = Isolate::Current(); |
720 Heap* heap = isolate->heap(); | 721 Heap* heap = isolate->heap(); |
721 | 722 |
722 // TODO(iposva): Get a proper halt instruction from the assembler. | 723 // TODO(iposva): Get a proper halt instruction from the assembler. |
723 uword address = heap->Allocate(size, space); | 724 uword address = heap->Allocate(size, space); |
| 725 if (address == 0) { |
| 726 // Use the preallocated out of memory exception to avoid calling |
| 727 // into dart code or allocating any code. |
| 728 const Instance& exception = |
| 729 Instance::Handle(isolate->object_store()->out_of_memory()); |
| 730 Exceptions::Throw(exception); |
| 731 UNREACHABLE(); |
| 732 } |
724 NoGCScope no_gc; | 733 NoGCScope no_gc; |
725 InitializeObject(address, size); | 734 InitializeObject(address, size); |
726 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); | 735 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); |
727 raw_obj->ptr()->class_ = cls.raw(); | 736 raw_obj->ptr()->class_ = cls.raw(); |
728 raw_obj->ptr()->tags_ = 0; | 737 raw_obj->ptr()->tags_ = 0; |
729 return raw_obj; | 738 return raw_obj; |
730 } | 739 } |
731 | 740 |
732 | 741 |
733 RawString* Class::Name() const { | 742 RawString* Class::Name() const { |
(...skipping 6757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7491 const String& str = String::Handle(pattern()); | 7500 const String& str = String::Handle(pattern()); |
7492 const char* format = "JSRegExp: pattern=%s flags=%s"; | 7501 const char* format = "JSRegExp: pattern=%s flags=%s"; |
7493 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 7502 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
7494 char* chars = reinterpret_cast<char*>( | 7503 char* chars = reinterpret_cast<char*>( |
7495 Isolate::Current()->current_zone()->Allocate(len + 1)); | 7504 Isolate::Current()->current_zone()->Allocate(len + 1)); |
7496 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 7505 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
7497 return chars; | 7506 return chars; |
7498 } | 7507 } |
7499 | 7508 |
7500 } // namespace dart | 7509 } // namespace dart |
OLD | NEW |