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

Side by Side Diff: runtime/vm/object.cc

Issue 10830131: Adding deopt info to code object. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 RawClass* Object::library_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 80 RawClass* Object::library_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
81 RawClass* Object::library_prefix_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 81 RawClass* Object::library_prefix_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
82 RawClass* Object::code_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 82 RawClass* Object::code_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
83 RawClass* Object::instructions_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 83 RawClass* Object::instructions_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
84 RawClass* Object::pc_descriptors_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 84 RawClass* Object::pc_descriptors_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
85 RawClass* Object::stackmap_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 85 RawClass* Object::stackmap_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
86 RawClass* Object::var_descriptors_class_ = 86 RawClass* Object::var_descriptors_class_ =
87 reinterpret_cast<RawClass*>(RAW_NULL); 87 reinterpret_cast<RawClass*>(RAW_NULL);
88 RawClass* Object::exception_handlers_class_ = 88 RawClass* Object::exception_handlers_class_ =
89 reinterpret_cast<RawClass*>(RAW_NULL); 89 reinterpret_cast<RawClass*>(RAW_NULL);
90 RawClass* Object::deopt_info_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
90 RawClass* Object::context_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 91 RawClass* Object::context_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
91 RawClass* Object::context_scope_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 92 RawClass* Object::context_scope_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
92 RawClass* Object::icdata_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 93 RawClass* Object::icdata_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
93 RawClass* Object::subtypetestcache_class_ = 94 RawClass* Object::subtypetestcache_class_ =
94 reinterpret_cast<RawClass*>(RAW_NULL); 95 reinterpret_cast<RawClass*>(RAW_NULL);
95 RawClass* Object::api_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 96 RawClass* Object::api_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
96 RawClass* Object::language_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 97 RawClass* Object::language_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
97 RawClass* Object::unhandled_exception_class_ = 98 RawClass* Object::unhandled_exception_class_ =
98 reinterpret_cast<RawClass*>(RAW_NULL); 99 reinterpret_cast<RawClass*>(RAW_NULL);
99 RawClass* Object::unwind_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 100 RawClass* Object::unwind_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } else if (raw_class == instructions_class()) { 139 } else if (raw_class == instructions_class()) {
139 return kInstructionsClass; 140 return kInstructionsClass;
140 } else if (raw_class == pc_descriptors_class()) { 141 } else if (raw_class == pc_descriptors_class()) {
141 return kPcDescriptorsClass; 142 return kPcDescriptorsClass;
142 } else if (raw_class == stackmap_class()) { 143 } else if (raw_class == stackmap_class()) {
143 return kStackmapClass; 144 return kStackmapClass;
144 } else if (raw_class == var_descriptors_class()) { 145 } else if (raw_class == var_descriptors_class()) {
145 return kLocalVarDescriptorsClass; 146 return kLocalVarDescriptorsClass;
146 } else if (raw_class == exception_handlers_class()) { 147 } else if (raw_class == exception_handlers_class()) {
147 return kExceptionHandlersClass; 148 return kExceptionHandlersClass;
149 } else if (raw_class == deopt_info_class()) {
150 return kDeoptInfoClass;
148 } else if (raw_class == context_class()) { 151 } else if (raw_class == context_class()) {
149 return kContextClass; 152 return kContextClass;
150 } else if (raw_class == context_scope_class()) { 153 } else if (raw_class == context_scope_class()) {
151 return kContextScopeClass; 154 return kContextScopeClass;
152 } else if (raw_class == icdata_class()) { 155 } else if (raw_class == icdata_class()) {
153 return kICDataClass; 156 return kICDataClass;
154 } else if (raw_class == subtypetestcache_class()) { 157 } else if (raw_class == subtypetestcache_class()) {
155 return kSubtypeTestCacheClass; 158 return kSubtypeTestCacheClass;
156 } else if (raw_class == api_error_class()) { 159 } else if (raw_class == api_error_class()) {
157 return kApiErrorClass; 160 return kApiErrorClass;
(...skipping 26 matching lines...) Expand all
184 case kTokenStreamClass: return token_stream_class(); 187 case kTokenStreamClass: return token_stream_class();
185 case kScriptClass: return script_class(); 188 case kScriptClass: return script_class();
186 case kLibraryClass: return library_class(); 189 case kLibraryClass: return library_class();
187 case kLibraryPrefixClass: return library_prefix_class(); 190 case kLibraryPrefixClass: return library_prefix_class();
188 case kCodeClass: return code_class(); 191 case kCodeClass: return code_class();
189 case kInstructionsClass: return instructions_class(); 192 case kInstructionsClass: return instructions_class();
190 case kPcDescriptorsClass: return pc_descriptors_class(); 193 case kPcDescriptorsClass: return pc_descriptors_class();
191 case kStackmapClass: return stackmap_class(); 194 case kStackmapClass: return stackmap_class();
192 case kLocalVarDescriptorsClass: return var_descriptors_class(); 195 case kLocalVarDescriptorsClass: return var_descriptors_class();
193 case kExceptionHandlersClass: return exception_handlers_class(); 196 case kExceptionHandlersClass: return exception_handlers_class();
197 case kDeoptInfoClass: return deopt_info_class();
194 case kContextClass: return context_class(); 198 case kContextClass: return context_class();
195 case kContextScopeClass: return context_scope_class(); 199 case kContextScopeClass: return context_scope_class();
196 case kICDataClass: return icdata_class(); 200 case kICDataClass: return icdata_class();
197 case kSubtypeTestCacheClass: return subtypetestcache_class(); 201 case kSubtypeTestCacheClass: return subtypetestcache_class();
198 case kApiErrorClass: return api_error_class(); 202 case kApiErrorClass: return api_error_class();
199 case kLanguageErrorClass: return language_error_class(); 203 case kLanguageErrorClass: return language_error_class();
200 case kUnhandledExceptionClass: return unhandled_exception_class(); 204 case kUnhandledExceptionClass: return unhandled_exception_class();
201 case kUnwindErrorClass: return unwind_error_class(); 205 case kUnwindErrorClass: return unwind_error_class();
202 default: break; 206 default: break;
203 } 207 }
(...skipping 19 matching lines...) Expand all
223 case kTokenStreamClass: return "TokenStream"; 227 case kTokenStreamClass: return "TokenStream";
224 case kScriptClass: return "Script"; 228 case kScriptClass: return "Script";
225 case kLibraryClass: return "Library"; 229 case kLibraryClass: return "Library";
226 case kLibraryPrefixClass: return "LibraryPrefix"; 230 case kLibraryPrefixClass: return "LibraryPrefix";
227 case kCodeClass: return "Code"; 231 case kCodeClass: return "Code";
228 case kInstructionsClass: return "Instructions"; 232 case kInstructionsClass: return "Instructions";
229 case kPcDescriptorsClass: return "PcDescriptors"; 233 case kPcDescriptorsClass: return "PcDescriptors";
230 case kStackmapClass: return "Stackmap"; 234 case kStackmapClass: return "Stackmap";
231 case kLocalVarDescriptorsClass: return "LocalVarDescriptors"; 235 case kLocalVarDescriptorsClass: return "LocalVarDescriptors";
232 case kExceptionHandlersClass: return "ExceptionHandlers"; 236 case kExceptionHandlersClass: return "ExceptionHandlers";
237 case kDeoptInfoClass: return "DeoptInfo";
233 case kContextClass: return "Context"; 238 case kContextClass: return "Context";
234 case kContextScopeClass: return "ContextScope"; 239 case kContextScopeClass: return "ContextScope";
235 case kICDataClass: return "ICData"; 240 case kICDataClass: return "ICData";
236 case kSubtypeTestCacheClass: return "SubtypeTestCache"; 241 case kSubtypeTestCacheClass: return "SubtypeTestCache";
237 case kApiErrorClass: return "ApiError"; 242 case kApiErrorClass: return "ApiError";
238 case kLanguageErrorClass: return "LanguageError"; 243 case kLanguageErrorClass: return "LanguageError";
239 case kUnhandledExceptionClass: return "UnhandledException"; 244 case kUnhandledExceptionClass: return "UnhandledException";
240 case kUnwindErrorClass: return "UnwindError"; 245 case kUnwindErrorClass: return "UnwindError";
241 default: break; 246 default: break;
242 } 247 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 393
389 cls = Class::New<Stackmap>(); 394 cls = Class::New<Stackmap>();
390 stackmap_class_ = cls.raw(); 395 stackmap_class_ = cls.raw();
391 396
392 cls = Class::New<LocalVarDescriptors>(); 397 cls = Class::New<LocalVarDescriptors>();
393 var_descriptors_class_ = cls.raw(); 398 var_descriptors_class_ = cls.raw();
394 399
395 cls = Class::New<ExceptionHandlers>(); 400 cls = Class::New<ExceptionHandlers>();
396 exception_handlers_class_ = cls.raw(); 401 exception_handlers_class_ = cls.raw();
397 402
403 cls = Class::New<DeoptInfo>();
404 deopt_info_class_ = cls.raw();
405
398 cls = Class::New<Context>(); 406 cls = Class::New<Context>();
399 context_class_ = cls.raw(); 407 context_class_ = cls.raw();
400 408
401 cls = Class::New<ContextScope>(); 409 cls = Class::New<ContextScope>();
402 context_scope_class_ = cls.raw(); 410 context_scope_class_ = cls.raw();
403 411
404 cls = Class::New<ICData>(); 412 cls = Class::New<ICData>();
405 icdata_class_ = cls.raw(); 413 icdata_class_ = cls.raw();
406 414
407 cls = Class::New<SubtypeTestCache>(); 415 cls = Class::New<SubtypeTestCache>();
(...skipping 6138 matching lines...) Expand 10 before | Expand all | Expand 10 after
6546 return Smi::Value(*SmiAddr(index, kTokenIndexEntry)); 6554 return Smi::Value(*SmiAddr(index, kTokenIndexEntry));
6547 } 6555 }
6548 6556
6549 6557
6550 void PcDescriptors::SetTokenIndex(intptr_t index, intptr_t value) const { 6558 void PcDescriptors::SetTokenIndex(intptr_t index, intptr_t value) const {
6551 *SmiAddr(index, kTokenIndexEntry) = Smi::New(value); 6559 *SmiAddr(index, kTokenIndexEntry) = Smi::New(value);
6552 } 6560 }
6553 6561
6554 6562
6555 intptr_t PcDescriptors::TryIndex(intptr_t index) const { 6563 intptr_t PcDescriptors::TryIndex(intptr_t index) const {
6564 ASSERT(DescriptorKind(index) != kDeoptIndex);
6565 return *(EntryAddr(index, kTryIndexEntry));
6566 }
6567
6568
6569 intptr_t PcDescriptors::DeoptIndex(intptr_t index) const {
6570 ASSERT(DescriptorKind(index) == kDeoptIndex);
6556 return *(EntryAddr(index, kTryIndexEntry)); 6571 return *(EntryAddr(index, kTryIndexEntry));
6557 } 6572 }
6558 6573
6559 6574
6560 void PcDescriptors::SetTryIndex(intptr_t index, intptr_t value) const { 6575 void PcDescriptors::SetTryIndex(intptr_t index, intptr_t value) const {
6561 *(EntryAddr(index, kTryIndexEntry)) = value; 6576 *(EntryAddr(index, kTryIndexEntry)) = value;
6562 } 6577 }
6563 6578
6564 6579
6565 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) { 6580 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) {
(...skipping 12 matching lines...) Expand all
6578 NoGCScope no_gc; 6593 NoGCScope no_gc;
6579 result ^= raw; 6594 result ^= raw;
6580 result.SetLength(num_descriptors); 6595 result.SetLength(num_descriptors);
6581 } 6596 }
6582 return result.raw(); 6597 return result.raw();
6583 } 6598 }
6584 6599
6585 6600
6586 const char* PcDescriptors::KindAsStr(intptr_t index) const { 6601 const char* PcDescriptors::KindAsStr(intptr_t index) const {
6587 switch (DescriptorKind(index)) { 6602 switch (DescriptorKind(index)) {
6588 case PcDescriptors::kDeopt: return "deopt"; 6603 case PcDescriptors::kDeopt: return "deopt ";
6589 case PcDescriptors::kPatchCode: return "patch"; 6604 case PcDescriptors::kDeoptIndex: return "deopt-ix";
6590 case PcDescriptors::kIcCall: return "ic-call"; 6605 case PcDescriptors::kPatchCode: return "patch ";
6591 case PcDescriptors::kFuncCall: return "fn-call"; 6606 case PcDescriptors::kIcCall: return "ic-call ";
6592 case PcDescriptors::kReturn: return "return"; 6607 case PcDescriptors::kFuncCall: return "fn-call ";
6593 case PcDescriptors::kOther: return "other"; 6608 case PcDescriptors::kReturn: return "return ";
6609 case PcDescriptors::kOther: return "other ";
6594 } 6610 }
6595 UNREACHABLE(); 6611 UNREACHABLE();
6596 return ""; 6612 return "";
6597 } 6613 }
6598 6614
6599 6615
6600 const char* PcDescriptors::ToCString() const { 6616 const char* PcDescriptors::ToCString() const {
6601 if (Length() == 0) { 6617 if (Length() == 0) {
6602 return "No pc descriptors\n"; 6618 return "No pc descriptors\n";
6603 } 6619 }
6604 const char* kFormat = "0x%x\t%s\t%ld\t%ld\t%ld\n"; 6620 const char* kFormat = "0x%x\t%s\t%ld\t%ld\t%ld\n";
6605 // First compute the buffer size required. 6621 // First compute the buffer size required.
6606 intptr_t len = 0; 6622 intptr_t len = 0;
6607 for (intptr_t i = 0; i < Length(); i++) { 6623 for (intptr_t i = 0; i < Length(); i++) {
6624 const intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ?
6625 DeoptIndex(i) : TryIndex(i);
6608 len += OS::SNPrint(NULL, 0, kFormat, 6626 len += OS::SNPrint(NULL, 0, kFormat,
6609 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i)); 6627 PC(i), KindAsStr(i), NodeId(i), TokenIndex(i), multi_purpose_index);
6610 } 6628 }
6611 // Allocate the buffer. 6629 // Allocate the buffer.
6612 char* buffer = reinterpret_cast<char*>( 6630 char* buffer = reinterpret_cast<char*>(
6613 Isolate::Current()->current_zone()->Allocate(len + 1)); 6631 Isolate::Current()->current_zone()->Allocate(len + 1));
6614 // Layout the fields in the buffer. 6632 // Layout the fields in the buffer.
6615 intptr_t index = 0; 6633 intptr_t index = 0;
6616 for (intptr_t i = 0; i < Length(); i++) { 6634 for (intptr_t i = 0; i < Length(); i++) {
6635 const intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ?
6636 DeoptIndex(i) : TryIndex(i);
6617 index += OS::SNPrint((buffer + index), (len - index), kFormat, 6637 index += OS::SNPrint((buffer + index), (len - index), kFormat,
6618 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i)); 6638 PC(i), KindAsStr(i), NodeId(i), TokenIndex(i), multi_purpose_index);
6619 } 6639 }
6620 return buffer; 6640 return buffer;
6621 } 6641 }
6622 6642
6623 6643
6624 // Verify assumptions (in debug mode only). 6644 // Verify assumptions (in debug mode only).
6625 // - No two deopt descriptors have the same node id (deoptimization). 6645 // - No two deopt descriptors have the same node id (deoptimization).
6626 // - No two ic-call descriptors have the same node id (type feedback). 6646 // - No two ic-call descriptors have the same node id (type feedback).
6627 // - No two descriptors of same kind have the same PC. 6647 // - No two descriptors of same kind have the same PC.
6628 // A function without unique ids is marked as non-optimizable (e.g., because of 6648 // A function without unique ids is marked as non-optimizable (e.g., because of
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
6884 index += OS::SNPrint((buffer + index), 6904 index += OS::SNPrint((buffer + index),
6885 (len - index), 6905 (len - index),
6886 "%ld => 0x%x\n", 6906 "%ld => 0x%x\n",
6887 TryIndex(i), 6907 TryIndex(i),
6888 HandlerPC(i)); 6908 HandlerPC(i));
6889 } 6909 }
6890 return buffer; 6910 return buffer;
6891 } 6911 }
6892 6912
6893 6913
6914 intptr_t DeoptInfo::Length() const {
6915 return Smi::Value(raw_ptr()->length_);
6916 }
6917
6918
6919 intptr_t DeoptInfo::FromIndex(intptr_t index) const {
6920 return *(EntryAddr(index, kFromIndex));
6921 }
6922
siva 2012/08/02 16:57:37 For better readability it might make sense to also
srdjan 2012/08/02 17:51:44 Done
6923
6924 intptr_t DeoptInfo::Instruction(intptr_t index) const {
6925 return *(EntryAddr(index, kInstruction));
6926 }
6927
6928
6929 const char* DeoptInfo::ToCString() const {
6930 if (Length() == 0) {
6931 return "No DeoptInfo";
6932 }
6933 // First compute the buffer size required.
6934 intptr_t len = 0;
6935 for (intptr_t i = 0; i < Length(); i++) {
6936 len += OS::SNPrint(NULL, 0, "[%d(%d):%d]",
6937 Instruction(i), FromIndex(i), i);
6938 }
6939 // Allocate the buffer.
6940 char* buffer = reinterpret_cast<char*>(
6941 Isolate::Current()->current_zone()->Allocate(len + 1));
6942 // Layout the fields in the buffer.
6943 intptr_t index = 0;
6944 for (intptr_t i = 0; i < Length(); i++) {
6945 index += OS::SNPrint((buffer + index),
6946 (len - index),
6947 "[%d(%d):%d]",
6948 Instruction(i),
6949 FromIndex(i),
6950 i);
6951 }
6952 return buffer;
6953 }
6954
6955
6956 RawDeoptInfo* DeoptInfo::New(intptr_t num_commands) {
6957 ASSERT(Object::deopt_info_class() != Class::null());
6958 DeoptInfo& result = DeoptInfo::Handle();
6959 {
6960 uword size = DeoptInfo::InstanceSize(num_commands);
6961 RawObject* raw = Object::Allocate(DeoptInfo::kInstanceKind,
6962 size,
6963 Heap::kOld);
6964 NoGCScope no_gc;
6965 result ^= raw;
6966 result.SetLength(num_commands);
6967 }
6968 return result.raw();
6969 }
6970
6971
6972 void DeoptInfo::SetLength(intptr_t value) const {
6973 // This is only safe because we create a new Smi, which does not cause
6974 // heap allocation.
6975 raw_ptr()->length_ = Smi::New(value);
6976 }
6977
6978
6979 void DeoptInfo::SetAt(intptr_t index,
6980 intptr_t instr_kind,
6981 intptr_t from_index) const {
6982 *(EntryAddr(index, kInstruction)) = instr_kind;
6983 *(EntryAddr(index, kFromIndex)) = from_index;
6984 }
6985
6986
6894 Code::Comments& Code::Comments::New(intptr_t count) { 6987 Code::Comments& Code::Comments::New(intptr_t count) {
6895 Comments* comments; 6988 Comments* comments;
6896 if (count < 0 || count > (kIntptrMax / kNumberOfEntries)) { 6989 if (count < 0 || count > (kIntptrMax / kNumberOfEntries)) {
6897 // This should be caught before we reach here. 6990 // This should be caught before we reach here.
6898 FATAL1("Fatal error in Code::Comments::New: invalid count %ld\n", count); 6991 FATAL1("Fatal error in Code::Comments::New: invalid count %ld\n", count);
6899 } 6992 }
6900 if (count == 0) { 6993 if (count == 0) {
6901 comments = new Comments(Array::Empty()); 6994 comments = new Comments(Array::Empty());
6902 } else { 6995 } else {
6903 comments = new Comments(Array::New(count * kNumberOfEntries)); 6996 comments = new Comments(Array::New(count * kNumberOfEntries));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
6940 Code::Comments::Comments(RawArray* comments) 7033 Code::Comments::Comments(RawArray* comments)
6941 : comments_(Array::Handle(comments)) { 7034 : comments_(Array::Handle(comments)) {
6942 } 7035 }
6943 7036
6944 7037
6945 void Code::set_stackmaps(const Array& maps) const { 7038 void Code::set_stackmaps(const Array& maps) const {
6946 StorePointer(&raw_ptr()->stackmaps_, maps.raw()); 7039 StorePointer(&raw_ptr()->stackmaps_, maps.raw());
6947 } 7040 }
6948 7041
6949 7042
7043 void Code::set_deopt_info_array(const Array& array) const {
7044 StorePointer(&raw_ptr()->deopt_info_array_, array.raw());
7045 }
7046
7047
7048 void Code::set_object_table(const Array& array) const {
7049 StorePointer(&raw_ptr()->object_table_, array.raw());
7050 }
7051
7052
6950 const Code::Comments& Code::comments() const { 7053 const Code::Comments& Code::comments() const {
6951 Comments* comments = new Code::Comments(raw_ptr()->comments_); 7054 Comments* comments = new Code::Comments(raw_ptr()->comments_);
6952 return *comments; 7055 return *comments;
6953 } 7056 }
6954 7057
6955 7058
6956 void Code::set_comments(const Code::Comments& comments) const { 7059 void Code::set_comments(const Code::Comments& comments) const {
6957 StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); 7060 StorePointer(&raw_ptr()->comments_, comments.comments_.raw());
6958 } 7061 }
6959 7062
6960 7063
6961 RawCode* Code::New(intptr_t pointer_offsets_length) { 7064 RawCode* Code::New(intptr_t pointer_offsets_length) {
6962 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { 7065 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) {
6963 // This should be caught before we reach here. 7066 // This should be caught before we reach here.
6964 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %ld\n", 7067 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %ld\n",
6965 pointer_offsets_length); 7068 pointer_offsets_length);
6966 } 7069 }
6967 ASSERT(Object::code_class() != Class::null()); 7070 ASSERT(Object::code_class() != Class::null());
6968 Code& result = Code::Handle(); 7071 Code& result = Code::Handle();
6969 { 7072 {
6970 uword size = Code::InstanceSize(pointer_offsets_length); 7073 uword size = Code::InstanceSize(pointer_offsets_length);
6971 RawObject* raw = Object::Allocate(Code::kInstanceKind, size, Heap::kOld); 7074 RawObject* raw = Object::Allocate(Code::kInstanceKind, size, Heap::kOld);
6972 NoGCScope no_gc; 7075 NoGCScope no_gc;
6973 result ^= raw; 7076 result ^= raw;
6974 result.set_pointer_offsets_length(pointer_offsets_length); 7077 result.set_pointer_offsets_length(pointer_offsets_length);
6975 result.set_is_optimized(false); 7078 result.set_is_optimized(false);
6976 result.set_comments(Comments::New(0)); 7079 result.set_comments(Comments::New(0));
7080 result.set_deopt_info_array(Array::Handle(Array::Empty()));
7081 result.set_object_table(Array::Handle(Array::Empty()));
siva 2012/08/02 16:57:37 Is there an advantage to initializing these to emp
srdjan 2012/08/02 17:51:44 Removed code, setting them to NULL.
6977 } 7082 }
6978 return result.raw(); 7083 return result.raw();
6979 } 7084 }
6980 7085
6981 7086
6982 RawCode* Code::FinalizeCode(const char* name, Assembler* assembler) { 7087 RawCode* Code::FinalizeCode(const char* name, Assembler* assembler) {
6983 ASSERT(assembler != NULL); 7088 ASSERT(assembler != NULL);
6984 7089
6985 // Allocate the Instructions object. 7090 // Allocate the Instructions object.
6986 Instructions& instrs = 7091 Instructions& instrs =
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
7129 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); 7234 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
7130 for (intptr_t i = 0; i < descriptors.Length(); i++) { 7235 for (intptr_t i = 0; i < descriptors.Length(); i++) {
7131 if (descriptors.DescriptorKind(i) == PcDescriptors::kPatchCode) { 7236 if (descriptors.DescriptorKind(i) == PcDescriptors::kPatchCode) {
7132 return descriptors.PC(i); 7237 return descriptors.PC(i);
7133 } 7238 }
7134 } 7239 }
7135 return 0; 7240 return 0;
7136 } 7241 }
7137 7242
7138 7243
7139 bool Code::ObjectExistInArea(intptr_t start_offset, intptr_t end_offset) const { 7244 bool Code::ObjectExistsInArea(intptr_t start_offset,
7245 intptr_t end_offset) const {
7140 for (intptr_t i = 0; i < this->pointer_offsets_length(); i++) { 7246 for (intptr_t i = 0; i < this->pointer_offsets_length(); i++) {
7141 const intptr_t offset = this->GetPointerOffsetAt(i); 7247 const intptr_t offset = this->GetPointerOffsetAt(i);
7142 if ((start_offset <= offset) && (offset < end_offset)) { 7248 if ((start_offset <= offset) && (offset < end_offset)) {
7143 return false; 7249 return false;
7144 } 7250 }
7145 } 7251 }
7146 return true; 7252 return true;
7147 } 7253 }
7148 7254
7149 7255
(...skipping 3812 matching lines...) Expand 10 before | Expand all | Expand 10 after
10962 const String& str = String::Handle(pattern()); 11068 const String& str = String::Handle(pattern());
10963 const char* format = "JSRegExp: pattern=%s flags=%s"; 11069 const char* format = "JSRegExp: pattern=%s flags=%s";
10964 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 11070 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10965 char* chars = reinterpret_cast<char*>( 11071 char* chars = reinterpret_cast<char*>(
10966 Isolate::Current()->current_zone()->Allocate(len + 1)); 11072 Isolate::Current()->current_zone()->Allocate(len + 1));
10967 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 11073 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10968 return chars; 11074 return chars;
10969 } 11075 }
10970 11076
10971 } // namespace dart 11077 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698