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 27 matching lines...) Expand all Loading... |
6133 } | 6135 } |
6134 | 6136 |
6135 // Hook up Code and Instruction objects. | 6137 // Hook up Code and Instruction objects. |
6136 instrs.set_code(code.raw()); | 6138 instrs.set_code(code.raw()); |
6137 code.set_instructions(instrs.raw()); | 6139 code.set_instructions(instrs.raw()); |
6138 } | 6140 } |
6139 return code.raw(); | 6141 return code.raw(); |
6140 } | 6142 } |
6141 | 6143 |
6142 | 6144 |
6143 RawCode* Code::FinalizeCode(const char* name, Assembler* assembler) { | 6145 RawCode* Code::FinalizeCode(const Function& function, Assembler* assembler) { |
6144 return FinalizeCode(name, assembler, Heap::kDartCode); | 6146 // Calling ToFullyQualifiedCString is very expensive, try to avoid it. |
| 6147 if (FLAG_generate_gdb_symbols || (Dart::pprof_symbol_generator() != NULL)) { |
| 6148 return FinalizeCode(function.ToFullyQualifiedCString(), |
| 6149 assembler, |
| 6150 Heap::kDartCode); |
| 6151 } else { |
| 6152 return FinalizeCode("", assembler, Heap::kDartCode); |
| 6153 } |
6145 } | 6154 } |
6146 | 6155 |
6147 | 6156 |
6148 RawCode* Code::FinalizeStubCode(const char* name, Assembler* assembler) { | 6157 RawCode* Code::FinalizeStubCode(const char* name, Assembler* assembler) { |
6149 return FinalizeCode(name, assembler, Heap::kStubCode); | 6158 return FinalizeCode(name, assembler, Heap::kStubCode); |
6150 } | 6159 } |
6151 | 6160 |
6152 | 6161 |
6153 intptr_t Code::GetTokenIndexOfPC(uword pc) const { | 6162 intptr_t Code::GetTokenIndexOfPC(uword pc) const { |
6154 intptr_t token_index = -1; | 6163 intptr_t token_index = -1; |
(...skipping 3729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9884 const String& str = String::Handle(pattern()); | 9893 const String& str = String::Handle(pattern()); |
9885 const char* format = "JSRegExp: pattern=%s flags=%s"; | 9894 const char* format = "JSRegExp: pattern=%s flags=%s"; |
9886 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 9895 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
9887 char* chars = reinterpret_cast<char*>( | 9896 char* chars = reinterpret_cast<char*>( |
9888 Isolate::Current()->current_zone()->Allocate(len + 1)); | 9897 Isolate::Current()->current_zone()->Allocate(len + 1)); |
9889 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 9898 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
9890 return chars; | 9899 return chars; |
9891 } | 9900 } |
9892 | 9901 |
9893 } // namespace dart | 9902 } // namespace dart |
OLD | NEW |