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

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

Issue 11412106: Support VTune's JIT interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 8 years 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
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/vm.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "vm/bootstrap.h" 11 #include "vm/bootstrap.h"
12 #include "vm/class_finalizer.h" 12 #include "vm/class_finalizer.h"
13 #include "vm/code_generator.h" 13 #include "vm/code_generator.h"
14 #include "vm/code_observers.h"
14 #include "vm/code_patcher.h" 15 #include "vm/code_patcher.h"
15 #include "vm/compiler.h" 16 #include "vm/compiler.h"
16 #include "vm/compiler_stats.h" 17 #include "vm/compiler_stats.h"
17 #include "vm/dart.h" 18 #include "vm/dart.h"
18 #include "vm/dart_api_state.h" 19 #include "vm/dart_api_state.h"
19 #include "vm/dart_entry.h" 20 #include "vm/dart_entry.h"
20 #include "vm/datastream.h" 21 #include "vm/datastream.h"
21 #include "vm/debuginfo.h"
22 #include "vm/deopt_instructions.h" 22 #include "vm/deopt_instructions.h"
23 #include "vm/double_conversion.h" 23 #include "vm/double_conversion.h"
24 #include "vm/exceptions.h" 24 #include "vm/exceptions.h"
25 #include "vm/growable_array.h" 25 #include "vm/growable_array.h"
26 #include "vm/heap.h" 26 #include "vm/heap.h"
27 #include "vm/object_store.h" 27 #include "vm/object_store.h"
28 #include "vm/parser.h" 28 #include "vm/parser.h"
29 #include "vm/runtime_entry.h" 29 #include "vm/runtime_entry.h"
30 #include "vm/scopes.h" 30 #include "vm/scopes.h"
31 #include "vm/stack_frame.h" 31 #include "vm/stack_frame.h"
32 #include "vm/symbols.h" 32 #include "vm/symbols.h"
33 #include "vm/timer.h" 33 #include "vm/timer.h"
34 #include "vm/unicode.h" 34 #include "vm/unicode.h"
35 35
36 namespace dart { 36 namespace dart {
37 37
38 DEFINE_FLAG(bool, generate_gdb_symbols, false,
39 "Generate symbols of generated dart functions for debugging with GDB");
40 DEFINE_FLAG(bool, show_internal_names, false, 38 DEFINE_FLAG(bool, show_internal_names, false,
41 "Show names of internal classes (e.g. \"OneByteString\") in error messages " 39 "Show names of internal classes (e.g. \"OneByteString\") in error messages "
42 "instead of showing the corresponding interface names (e.g. \"String\")"); 40 "instead of showing the corresponding interface names (e.g. \"String\")");
43 DEFINE_FLAG(bool, trace_disabling_optimized_code, false, 41 DEFINE_FLAG(bool, trace_disabling_optimized_code, false,
44 "Trace disabling optimized code."); 42 "Trace disabling optimized code.");
45 DECLARE_FLAG(bool, trace_compiler); 43 DECLARE_FLAG(bool, trace_compiler);
46 DECLARE_FLAG(bool, eliminate_type_checks); 44 DECLARE_FLAG(bool, eliminate_type_checks);
47 DECLARE_FLAG(bool, enable_type_checks); 45 DECLARE_FLAG(bool, enable_type_checks);
48 46
49 static const char* kGetterPrefix = "get:"; 47 static const char* kGetterPrefix = "get:";
(...skipping 7075 matching lines...) Expand 10 before | Expand all | Expand 10 after
7125 7123
7126 // Allocate the Instructions object. 7124 // Allocate the Instructions object.
7127 Instructions& instrs = 7125 Instructions& instrs =
7128 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); 7126 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize()));
7129 7127
7130 // Copy the instructions into the instruction area and apply all fixups. 7128 // Copy the instructions into the instruction area and apply all fixups.
7131 // Embedded pointers are still in handles at this point. 7129 // Embedded pointers are still in handles at this point.
7132 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), 7130 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()),
7133 instrs.size()); 7131 instrs.size());
7134 assembler->FinalizeInstructions(region); 7132 assembler->FinalizeInstructions(region);
7135 Dart_FileWriterFunction perf_events_writer = Dart::perf_events_writer(); 7133
7136 if (perf_events_writer != NULL) { 7134 CodeObservers::NotifyAll(name,
7137 const char* format = "%"Px" %"Px" %s%s\n"; 7135 instrs.EntryPoint(),
7138 uword addr = instrs.EntryPoint(); 7136 assembler->prologue_offset(),
7139 uword size = instrs.size(); 7137 instrs.size(),
7140 const char* marker = optimized ? "*" : ""; 7138 optimized);
7141 intptr_t len = OS::SNPrint(NULL, 0, format, addr, size, marker, name);
7142 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
7143 OS::SNPrint(buffer, len + 1, format, addr, size, marker, name);
7144 (*perf_events_writer)(buffer, len);
7145 }
7146 DebugInfo* pprof_symbol_generator = Dart::pprof_symbol_generator();
7147 if (pprof_symbol_generator != NULL) {
7148 ASSERT(strlen(name) != 0);
7149 pprof_symbol_generator->AddCode(instrs.EntryPoint(), instrs.size());
7150 pprof_symbol_generator->AddCodeRegion(name,
7151 instrs.EntryPoint(),
7152 instrs.size());
7153 }
7154 if (FLAG_generate_gdb_symbols) {
7155 ASSERT(strlen(name) != 0);
7156 intptr_t prolog_offset = assembler->prolog_offset();
7157 if (prolog_offset > 0) {
7158 // In order to ensure that gdb sees the first instruction of a function
7159 // as the prolog sequence we register two symbols for the cases when
7160 // the prolog sequence is not the first instruction:
7161 // <name>_entry is used for code preceding the prolog sequence.
7162 // <name> for rest of the code (first instruction is prolog sequence).
7163 const char* kFormat = "%s_%s";
7164 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name, "entry");
7165 char* pname = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
7166 OS::SNPrint(pname, (len + 1), kFormat, name, "entry");
7167 DebugInfo::RegisterSection(pname, instrs.EntryPoint(), prolog_offset);
7168 DebugInfo::RegisterSection(name,
7169 (instrs.EntryPoint() + prolog_offset),
7170 (instrs.size() - prolog_offset));
7171 } else {
7172 DebugInfo::RegisterSection(name, instrs.EntryPoint(), instrs.size());
7173 }
7174 }
7175 7139
7176 const ZoneGrowableArray<int>& pointer_offsets = 7140 const ZoneGrowableArray<int>& pointer_offsets =
7177 assembler->GetPointerOffsets(); 7141 assembler->GetPointerOffsets();
7178 7142
7179 // Allocate the code object. 7143 // Allocate the code object.
7180 Code& code = Code::ZoneHandle(Code::New(pointer_offsets.length())); 7144 Code& code = Code::ZoneHandle(Code::New(pointer_offsets.length()));
7181 { 7145 {
7182 NoGCScope no_gc; 7146 NoGCScope no_gc;
7183 7147
7184 // Set pointer offsets list in Code object and resolve all handles in 7148 // Set pointer offsets list in Code object and resolve all handles in
(...skipping 11 matching lines...) Expand all
7196 code.set_instructions(instrs.raw()); 7160 code.set_instructions(instrs.raw());
7197 } 7161 }
7198 return code.raw(); 7162 return code.raw();
7199 } 7163 }
7200 7164
7201 7165
7202 RawCode* Code::FinalizeCode(const Function& function, 7166 RawCode* Code::FinalizeCode(const Function& function,
7203 Assembler* assembler, 7167 Assembler* assembler,
7204 bool optimized) { 7168 bool optimized) {
7205 // Calling ToFullyQualifiedCString is very expensive, try to avoid it. 7169 // Calling ToFullyQualifiedCString is very expensive, try to avoid it.
7206 if (FLAG_generate_gdb_symbols || 7170 if (CodeObservers::AreActive()) {
7207 Dart::perf_events_writer() != NULL ||
7208 Dart::pprof_symbol_generator() != NULL) {
7209 return FinalizeCode(function.ToFullyQualifiedCString(), 7171 return FinalizeCode(function.ToFullyQualifiedCString(),
7210 assembler, 7172 assembler,
7211 optimized); 7173 optimized);
7212 } else { 7174 } else {
7213 return FinalizeCode("", assembler); 7175 return FinalizeCode("", assembler);
7214 } 7176 }
7215 } 7177 }
7216 7178
7217 7179
7218 // Check if object matches find condition. 7180 // Check if object matches find condition.
(...skipping 4977 matching lines...) Expand 10 before | Expand all | Expand 10 after
12196 } 12158 }
12197 return result.raw(); 12159 return result.raw();
12198 } 12160 }
12199 12161
12200 12162
12201 const char* WeakProperty::ToCString() const { 12163 const char* WeakProperty::ToCString() const {
12202 return "_WeakProperty"; 12164 return "_WeakProperty";
12203 } 12165 }
12204 12166
12205 } // namespace dart 12167 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/vm.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698