Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 6054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6065 index += OS::SNPrint((buffer + index), | 6065 index += OS::SNPrint((buffer + index), |
| 6066 (len - index), | 6066 (len - index), |
| 6067 "%ld => 0x%x\n", | 6067 "%ld => 0x%x\n", |
| 6068 TryIndex(i), | 6068 TryIndex(i), |
| 6069 HandlerPC(i)); | 6069 HandlerPC(i)); |
| 6070 } | 6070 } |
| 6071 return buffer; | 6071 return buffer; |
| 6072 } | 6072 } |
| 6073 | 6073 |
| 6074 | 6074 |
| 6075 Code::Comments& Code::Comments::New(intptr_t count) { | |
| 6076 Comments* comments; | |
| 6077 if (count == 0) { | |
| 6078 comments = new Comments(Array::Handle()); | |
|
srdjan
2012/05/17 21:30:37
The other option would be to use Array::Empty() in
| |
| 6079 } else { | |
| 6080 comments = new Comments(Array::Handle( | |
| 6081 Array::New(count * kNumberOfEntries))); | |
| 6082 } | |
| 6083 return *comments; | |
| 6084 } | |
| 6085 | |
| 6086 | |
| 6087 intptr_t Code::Comments::Length() const { | |
| 6088 return comments_.IsNull() ? 0 : (comments_.Length() / kNumberOfEntries); | |
| 6089 } | |
| 6090 | |
| 6091 | |
| 6092 intptr_t Code::Comments::PCOffsetAt(intptr_t idx) const { | |
| 6093 return Smi::CheckedHandle( | |
| 6094 comments_.At(idx * kNumberOfEntries + kPCOffsetEntry)).Value(); | |
| 6095 } | |
| 6096 | |
| 6097 | |
| 6098 void Code::Comments::SetPCOffsetAt(intptr_t idx, intptr_t pc) { | |
| 6099 comments_.SetAt(idx * kNumberOfEntries + kPCOffsetEntry, | |
| 6100 Smi::Handle(Smi::New(pc))); | |
| 6101 } | |
| 6102 | |
| 6103 | |
| 6104 const String& Code::Comments::CommentAt(intptr_t idx) const { | |
| 6105 return String::CheckedHandle( | |
| 6106 comments_.At(idx * kNumberOfEntries + kCommentEntry)); | |
| 6107 } | |
| 6108 | |
| 6109 | |
| 6110 void Code::Comments::SetCommentAt(intptr_t idx, const String& comment) { | |
| 6111 comments_.SetAt(idx * kNumberOfEntries + kCommentEntry, comment); | |
| 6112 } | |
| 6113 | |
| 6114 | |
| 6115 Code::Comments::Comments(const Array& comments) | |
| 6116 : comments_(comments) { | |
| 6117 } | |
| 6118 | |
| 6119 | |
| 6075 void Code::set_stackmaps(const Array& maps) const { | 6120 void Code::set_stackmaps(const Array& maps) const { |
| 6076 StorePointer(&raw_ptr()->stackmaps_, maps.raw()); | 6121 StorePointer(&raw_ptr()->stackmaps_, maps.raw()); |
| 6077 } | 6122 } |
| 6078 | 6123 |
| 6079 | 6124 |
| 6125 const Code::Comments& Code::comments() const { | |
| 6126 Comments* comments = new Code::Comments(Array::Handle(raw_ptr()->comments_)); | |
| 6127 return *comments; | |
| 6128 } | |
| 6129 | |
| 6130 | |
| 6131 void Code::set_comments(const Code::Comments& comments) const { | |
| 6132 StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); | |
| 6133 } | |
| 6134 | |
| 6135 | |
| 6080 RawCode* Code::New(int pointer_offsets_length) { | 6136 RawCode* Code::New(int pointer_offsets_length) { |
| 6081 const Class& cls = Class::Handle(Object::code_class()); | 6137 const Class& cls = Class::Handle(Object::code_class()); |
| 6082 Code& result = Code::Handle(); | 6138 Code& result = Code::Handle(); |
| 6083 { | 6139 { |
| 6084 uword size = Code::InstanceSize(pointer_offsets_length); | 6140 uword size = Code::InstanceSize(pointer_offsets_length); |
| 6085 RawObject* raw = Object::Allocate(cls, size, Heap::kOld); | 6141 RawObject* raw = Object::Allocate(cls, size, Heap::kOld); |
| 6086 NoGCScope no_gc; | 6142 NoGCScope no_gc; |
| 6087 result ^= raw; | 6143 result ^= raw; |
| 6088 result.set_pointer_offsets_length(pointer_offsets_length); | 6144 result.set_pointer_offsets_length(pointer_offsets_length); |
| 6089 result.set_is_optimized(false); | 6145 result.set_is_optimized(false); |
| (...skipping 3853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9943 const String& str = String::Handle(pattern()); | 9999 const String& str = String::Handle(pattern()); |
| 9944 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10000 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 9945 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10001 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 9946 char* chars = reinterpret_cast<char*>( | 10002 char* chars = reinterpret_cast<char*>( |
| 9947 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10003 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 9948 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10004 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 9949 return chars; | 10005 return chars; |
| 9950 } | 10006 } |
| 9951 | 10007 |
| 9952 } // namespace dart | 10008 } // namespace dart |
| OLD | NEW |