| 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 6162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6173 return FinalizeCode("", assembler, Heap::kDartCode); | 6173 return FinalizeCode("", assembler, Heap::kDartCode); |
| 6174 } | 6174 } |
| 6175 } | 6175 } |
| 6176 | 6176 |
| 6177 | 6177 |
| 6178 RawCode* Code::FinalizeStubCode(const char* name, Assembler* assembler) { | 6178 RawCode* Code::FinalizeStubCode(const char* name, Assembler* assembler) { |
| 6179 return FinalizeCode(name, assembler, Heap::kStubCode); | 6179 return FinalizeCode(name, assembler, Heap::kStubCode); |
| 6180 } | 6180 } |
| 6181 | 6181 |
| 6182 | 6182 |
| 6183 // Check if object matches find condition. |
| 6184 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) { |
| 6185 return RawInstructions::ContainsPC(obj, pc_); |
| 6186 } |
| 6187 |
| 6188 |
| 6189 RawCode* Code::LookupCode(uword pc) { |
| 6190 Isolate* isolate = Isolate::Current(); |
| 6191 NoGCScope no_gc; |
| 6192 FindRawCodeVisitor visitor(pc); |
| 6193 RawInstructions* instr; |
| 6194 instr = isolate->heap()->FindObjectInCodeSpace(&visitor); |
| 6195 if (instr != Instructions::null()) { |
| 6196 return instr->ptr()->code_; |
| 6197 } |
| 6198 instr = isolate->heap()->FindObjectInStubCodeSpace(&visitor); |
| 6199 if (instr != Instructions::null()) { |
| 6200 return instr->ptr()->code_; |
| 6201 } |
| 6202 return Code::null(); |
| 6203 } |
| 6204 |
| 6205 |
| 6183 intptr_t Code::GetTokenIndexOfPC(uword pc) const { | 6206 intptr_t Code::GetTokenIndexOfPC(uword pc) const { |
| 6184 intptr_t token_index = -1; | 6207 intptr_t token_index = -1; |
| 6185 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 6208 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
| 6186 for (intptr_t i = 0; i < descriptors.Length(); i++) { | 6209 for (intptr_t i = 0; i < descriptors.Length(); i++) { |
| 6187 if (descriptors.PC(i) == pc) { | 6210 if (descriptors.PC(i) == pc) { |
| 6188 token_index = descriptors.TokenIndex(i); | 6211 token_index = descriptors.TokenIndex(i); |
| 6189 break; | 6212 break; |
| 6190 } | 6213 } |
| 6191 } | 6214 } |
| 6192 return token_index; | 6215 return token_index; |
| (...skipping 3502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9695 const GrowableArray<uword>& frame_pcs) const { | 9718 const GrowableArray<uword>& frame_pcs) const { |
| 9696 Isolate* isolate = Isolate::Current(); | 9719 Isolate* isolate = Isolate::Current(); |
| 9697 ASSERT(isolate != NULL); | 9720 ASSERT(isolate != NULL); |
| 9698 Function& function = Function::Handle(isolate, Function::null()); | 9721 Function& function = Function::Handle(isolate, Function::null()); |
| 9699 Code& code = Code::Handle(isolate, Code::null()); | 9722 Code& code = Code::Handle(isolate, Code::null()); |
| 9700 Smi& pc_offset = Smi::Handle(isolate, Smi::New(0)); | 9723 Smi& pc_offset = Smi::Handle(isolate, Smi::New(0)); |
| 9701 const Array& function_array = Array::Handle(raw_ptr()->function_array_); | 9724 const Array& function_array = Array::Handle(raw_ptr()->function_array_); |
| 9702 const Array& code_array = Array::Handle(raw_ptr()->code_array_); | 9725 const Array& code_array = Array::Handle(raw_ptr()->code_array_); |
| 9703 const Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_); | 9726 const Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_); |
| 9704 for (intptr_t i = 0; i < frame_pcs.length(); i++) { | 9727 for (intptr_t i = 0; i < frame_pcs.length(); i++) { |
| 9705 code = StackFrame::LookupCode(isolate, frame_pcs[i]); | 9728 code = Code::LookupCode(frame_pcs[i]); |
| 9706 ASSERT(!code.IsNull()); | 9729 ASSERT(!code.IsNull()); |
| 9707 function = code.function(); | 9730 function = code.function(); |
| 9708 function_array.SetAt((index + i), function); | 9731 function_array.SetAt((index + i), function); |
| 9709 code_array.SetAt((index + i), code); | 9732 code_array.SetAt((index + i), code); |
| 9710 pc_offset = Smi::New(frame_pcs[i] - code.EntryPoint()); | 9733 pc_offset = Smi::New(frame_pcs[i] - code.EntryPoint()); |
| 9711 pc_offset_array.SetAt((index + i), pc_offset); | 9734 pc_offset_array.SetAt((index + i), pc_offset); |
| 9712 } | 9735 } |
| 9713 } | 9736 } |
| 9714 | 9737 |
| 9715 | 9738 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9920 const String& str = String::Handle(pattern()); | 9943 const String& str = String::Handle(pattern()); |
| 9921 const char* format = "JSRegExp: pattern=%s flags=%s"; | 9944 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 9922 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 9945 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 9923 char* chars = reinterpret_cast<char*>( | 9946 char* chars = reinterpret_cast<char*>( |
| 9924 Isolate::Current()->current_zone()->Allocate(len + 1)); | 9947 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 9925 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 9948 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 9926 return chars; | 9949 return chars; |
| 9927 } | 9950 } |
| 9928 | 9951 |
| 9929 } // namespace dart | 9952 } // namespace dart |
| OLD | NEW |