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 6069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6080 Instructions& instrs = | 6080 Instructions& instrs = |
6081 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize(), space)); | 6081 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize(), space)); |
6082 | 6082 |
6083 // Copy the instructions into the instruction area and apply all fixups. | 6083 // Copy the instructions into the instruction area and apply all fixups. |
6084 // Embedded pointers are still in handles at this point. | 6084 // Embedded pointers are still in handles at this point. |
6085 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), | 6085 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), |
6086 instrs.size()); | 6086 instrs.size()); |
6087 assembler->FinalizeInstructions(region); | 6087 assembler->FinalizeInstructions(region); |
6088 DebugInfo* pprof_symbol_generator = Dart::pprof_symbol_generator(); | 6088 DebugInfo* pprof_symbol_generator = Dart::pprof_symbol_generator(); |
6089 if (pprof_symbol_generator != NULL) { | 6089 if (pprof_symbol_generator != NULL) { |
| 6090 ASSERT(strlen(name) != 0); |
6090 pprof_symbol_generator->AddCode(instrs.EntryPoint(), instrs.size()); | 6091 pprof_symbol_generator->AddCode(instrs.EntryPoint(), instrs.size()); |
6091 pprof_symbol_generator->AddCodeRegion(name, | 6092 pprof_symbol_generator->AddCodeRegion(name, |
6092 instrs.EntryPoint(), | 6093 instrs.EntryPoint(), |
6093 instrs.size()); | 6094 instrs.size()); |
6094 } | 6095 } |
6095 if (FLAG_generate_gdb_symbols) { | 6096 if (FLAG_generate_gdb_symbols) { |
| 6097 ASSERT(strlen(name) != 0); |
6096 intptr_t prolog_offset = assembler->prolog_offset(); | 6098 intptr_t prolog_offset = assembler->prolog_offset(); |
6097 if (prolog_offset > 0) { | 6099 if (prolog_offset > 0) { |
6098 // In order to ensure that gdb sees the first instruction of a function | 6100 // In order to ensure that gdb sees the first instruction of a function |
6099 // as the prolog sequence we register two symbols for the cases when | 6101 // as the prolog sequence we register two symbols for the cases when |
6100 // the prolog sequence is not the first instruction: | 6102 // the prolog sequence is not the first instruction: |
6101 // <name>_entry is used for code preceding the prolog sequence. | 6103 // <name>_entry is used for code preceding the prolog sequence. |
6102 // <name> for rest of the code (first instruction is prolog sequence). | 6104 // <name> for rest of the code (first instruction is prolog sequence). |
6103 const char* kFormat = "%s_%s"; | 6105 const char* kFormat = "%s_%s"; |
6104 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name, "entry"); | 6106 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name, "entry"); |
6105 char* pname = reinterpret_cast<char*>( | 6107 char* pname = reinterpret_cast<char*>( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6143 RawCode* Code::FinalizeCode(const char* name, Assembler* assembler) { | 6145 RawCode* Code::FinalizeCode(const char* name, Assembler* assembler) { |
6144 return FinalizeCode(name, assembler, Heap::kDartCode); | 6146 return FinalizeCode(name, assembler, Heap::kDartCode); |
6145 } | 6147 } |
6146 | 6148 |
6147 | 6149 |
6148 RawCode* Code::FinalizeStubCode(const char* name, Assembler* assembler) { | 6150 RawCode* Code::FinalizeStubCode(const char* name, Assembler* assembler) { |
6149 return FinalizeCode(name, assembler, Heap::kStubCode); | 6151 return FinalizeCode(name, assembler, Heap::kStubCode); |
6150 } | 6152 } |
6151 | 6153 |
6152 | 6154 |
| 6155 RawCode* Code::FinalizeCodeForFunction(const Function& function, |
| 6156 Assembler* assembler) { |
| 6157 // Calling ToFullyQualifiedCString is very expensive, try to avoid it. |
| 6158 if (FLAG_generate_gdb_symbols || (Dart::pprof_symbol_generator() != NULL)) { |
| 6159 return FinalizeCode(function.ToFullyQualifiedCString(), |
| 6160 assembler, |
| 6161 Heap::kDartCode); |
| 6162 } else { |
| 6163 return FinalizeCode("", assembler, Heap::kDartCode); |
| 6164 } |
| 6165 } |
| 6166 |
| 6167 |
6153 intptr_t Code::GetTokenIndexOfPC(uword pc) const { | 6168 intptr_t Code::GetTokenIndexOfPC(uword pc) const { |
6154 intptr_t token_index = -1; | 6169 intptr_t token_index = -1; |
6155 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 6170 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
6156 for (intptr_t i = 0; i < descriptors.Length(); i++) { | 6171 for (intptr_t i = 0; i < descriptors.Length(); i++) { |
6157 if (descriptors.PC(i) == pc) { | 6172 if (descriptors.PC(i) == pc) { |
6158 token_index = descriptors.TokenIndex(i); | 6173 token_index = descriptors.TokenIndex(i); |
6159 break; | 6174 break; |
6160 } | 6175 } |
6161 } | 6176 } |
6162 return token_index; | 6177 return token_index; |
(...skipping 3721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9884 const String& str = String::Handle(pattern()); | 9899 const String& str = String::Handle(pattern()); |
9885 const char* format = "JSRegExp: pattern=%s flags=%s"; | 9900 const char* format = "JSRegExp: pattern=%s flags=%s"; |
9886 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 9901 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
9887 char* chars = reinterpret_cast<char*>( | 9902 char* chars = reinterpret_cast<char*>( |
9888 Isolate::Current()->current_zone()->Allocate(len + 1)); | 9903 Isolate::Current()->current_zone()->Allocate(len + 1)); |
9889 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 9904 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
9890 return chars; | 9905 return chars; |
9891 } | 9906 } |
9892 | 9907 |
9893 } // namespace dart | 9908 } // namespace dart |
OLD | NEW |