| 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 "include/dart_api.h" |
| 7 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 8 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 9 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| 10 #include "vm/bootstrap.h" | 11 #include "vm/bootstrap.h" |
| 11 #include "vm/datastream.h" | 12 #include "vm/datastream.h" |
| 12 #include "vm/code_generator.h" | 13 #include "vm/code_generator.h" |
| 13 #include "vm/code_patcher.h" | 14 #include "vm/code_patcher.h" |
| 14 #include "vm/compiler.h" | 15 #include "vm/compiler.h" |
| 15 #include "vm/compiler_stats.h" | 16 #include "vm/compiler_stats.h" |
| 16 #include "vm/class_finalizer.h" | 17 #include "vm/class_finalizer.h" |
| (...skipping 6828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6845 | 6846 |
| 6846 // Allocate the Instructions object. | 6847 // Allocate the Instructions object. |
| 6847 Instructions& instrs = | 6848 Instructions& instrs = |
| 6848 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); | 6849 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); |
| 6849 | 6850 |
| 6850 // Copy the instructions into the instruction area and apply all fixups. | 6851 // Copy the instructions into the instruction area and apply all fixups. |
| 6851 // Embedded pointers are still in handles at this point. | 6852 // Embedded pointers are still in handles at this point. |
| 6852 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), | 6853 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), |
| 6853 instrs.size()); | 6854 instrs.size()); |
| 6854 assembler->FinalizeInstructions(region); | 6855 assembler->FinalizeInstructions(region); |
| 6856 Dart_FileWriterFunction perf_events_writer = Dart::perf_events_writer(); |
| 6857 if (perf_events_writer != NULL) { |
| 6858 const char* format = "%x %x %s\n"; |
| 6859 uword addr = instrs.EntryPoint(); |
| 6860 uword size = instrs.size(); |
| 6861 intptr_t len = OS::SNPrint(NULL, 0, format, addr, size, name); |
| 6862 char* buffer = reinterpret_cast<char*>( |
| 6863 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 6864 OS::SNPrint(buffer, len + 1, format, addr, size, name); |
| 6865 (*perf_events_writer)(buffer, len); |
| 6866 } |
| 6855 DebugInfo* pprof_symbol_generator = Dart::pprof_symbol_generator(); | 6867 DebugInfo* pprof_symbol_generator = Dart::pprof_symbol_generator(); |
| 6856 if (pprof_symbol_generator != NULL) { | 6868 if (pprof_symbol_generator != NULL) { |
| 6857 ASSERT(strlen(name) != 0); | 6869 ASSERT(strlen(name) != 0); |
| 6858 pprof_symbol_generator->AddCode(instrs.EntryPoint(), instrs.size()); | 6870 pprof_symbol_generator->AddCode(instrs.EntryPoint(), instrs.size()); |
| 6859 pprof_symbol_generator->AddCodeRegion(name, | 6871 pprof_symbol_generator->AddCodeRegion(name, |
| 6860 instrs.EntryPoint(), | 6872 instrs.EntryPoint(), |
| 6861 instrs.size()); | 6873 instrs.size()); |
| 6862 } | 6874 } |
| 6863 if (FLAG_generate_gdb_symbols) { | 6875 if (FLAG_generate_gdb_symbols) { |
| 6864 ASSERT(strlen(name) != 0); | 6876 ASSERT(strlen(name) != 0); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6904 // Hook up Code and Instruction objects. | 6916 // Hook up Code and Instruction objects. |
| 6905 instrs.set_code(code.raw()); | 6917 instrs.set_code(code.raw()); |
| 6906 code.set_instructions(instrs.raw()); | 6918 code.set_instructions(instrs.raw()); |
| 6907 } | 6919 } |
| 6908 return code.raw(); | 6920 return code.raw(); |
| 6909 } | 6921 } |
| 6910 | 6922 |
| 6911 | 6923 |
| 6912 RawCode* Code::FinalizeCode(const Function& function, Assembler* assembler) { | 6924 RawCode* Code::FinalizeCode(const Function& function, Assembler* assembler) { |
| 6913 // Calling ToFullyQualifiedCString is very expensive, try to avoid it. | 6925 // Calling ToFullyQualifiedCString is very expensive, try to avoid it. |
| 6914 if (FLAG_generate_gdb_symbols || (Dart::pprof_symbol_generator() != NULL)) { | 6926 if (FLAG_generate_gdb_symbols || |
| 6927 Dart::perf_events_writer() != NULL || |
| 6928 Dart::pprof_symbol_generator() != NULL) { |
| 6915 return FinalizeCode(function.ToFullyQualifiedCString(), assembler); | 6929 return FinalizeCode(function.ToFullyQualifiedCString(), assembler); |
| 6916 } else { | 6930 } else { |
| 6917 return FinalizeCode("", assembler); | 6931 return FinalizeCode("", assembler); |
| 6918 } | 6932 } |
| 6919 } | 6933 } |
| 6920 | 6934 |
| 6921 | 6935 |
| 6922 // Check if object matches find condition. | 6936 // Check if object matches find condition. |
| 6923 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) { | 6937 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) { |
| 6924 return RawInstructions::ContainsPC(obj, pc_); | 6938 return RawInstructions::ContainsPC(obj, pc_); |
| (...skipping 3950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10875 const String& str = String::Handle(pattern()); | 10889 const String& str = String::Handle(pattern()); |
| 10876 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10890 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 10877 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10891 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 10878 char* chars = reinterpret_cast<char*>( | 10892 char* chars = reinterpret_cast<char*>( |
| 10879 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10893 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 10880 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10894 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 10881 return chars; | 10895 return chars; |
| 10882 } | 10896 } |
| 10883 | 10897 |
| 10884 } // namespace dart | 10898 } // namespace dart |
| OLD | NEW |