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

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

Issue 10389023: Fixed compilation time measurement, restructure some code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months 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
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 "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 3635 matching lines...) Expand 10 before | Expand all | Expand 10 after
3646 reserve_len += OS::SNPrint(NULL, 0, function_format, name); 3646 reserve_len += OS::SNPrint(NULL, 0, function_format, name);
3647 const Function& parent = Function::Handle(function.parent_function()); 3647 const Function& parent = Function::Handle(function.parent_function());
3648 intptr_t written = 0; 3648 intptr_t written = 0;
3649 if (parent.IsNull()) { 3649 if (parent.IsNull()) {
3650 const Class& function_class = Class::Handle(function.owner()); 3650 const Class& function_class = Class::Handle(function.owner());
3651 ASSERT(!function_class.IsNull()); 3651 ASSERT(!function_class.IsNull());
3652 const char* class_name = String::Handle(function_class.Name()).ToCString(); 3652 const char* class_name = String::Handle(function_class.Name()).ToCString();
3653 ASSERT(class_name != NULL); 3653 ASSERT(class_name != NULL);
3654 const Library& library = Library::Handle(function_class.library()); 3654 const Library& library = Library::Handle(function_class.library());
3655 ASSERT(!library.IsNull()); 3655 ASSERT(!library.IsNull());
3656 const char* library_name = String::Handle(library.url()).ToCString(); 3656 const char* library_name = String::Handle(library.url()).ToCString();
hausner 2012/05/08 21:41:01 Extra space to balance the universe?
srdjan 2012/05/08 21:51:31 Rebalanced the universe.
3657 ASSERT(library_name != NULL); 3657 ASSERT(library_name != NULL);
3658 const char* lib_class_format = 3658 const char* lib_class_format =
3659 (library_name[0] == '\0') ? "%s%s_" : "%s_%s_"; 3659 (library_name[0] == '\0') ? "%s%s_" : "%s_%s_";
3660 reserve_len += 3660 reserve_len +=
3661 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name); 3661 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name);
3662 ASSERT(chars != NULL); 3662 ASSERT(chars != NULL);
3663 *chars = reinterpret_cast<char*>( 3663 *chars = reinterpret_cast<char*>(
3664 Isolate::Current()->current_zone()->Allocate(reserve_len + 1)); 3664 Isolate::Current()->current_zone()->Allocate(reserve_len + 1));
3665 written = OS::SNPrint( 3665 written = OS::SNPrint(
3666 *chars, reserve_len, lib_class_format, library_name, class_name); 3666 *chars, reserve_len, lib_class_format, library_name, class_name);
(...skipping 2395 matching lines...) Expand 10 before | Expand all | Expand 10 after
6062 { 6062 {
6063 uword size = Code::InstanceSize(pointer_offsets_length); 6063 uword size = Code::InstanceSize(pointer_offsets_length);
6064 RawObject* raw = Object::Allocate(cls, size, Heap::kOld); 6064 RawObject* raw = Object::Allocate(cls, size, Heap::kOld);
6065 NoGCScope no_gc; 6065 NoGCScope no_gc;
6066 result ^= raw; 6066 result ^= raw;
6067 result.set_pointer_offsets_length(pointer_offsets_length); 6067 result.set_pointer_offsets_length(pointer_offsets_length);
6068 result.set_is_optimized(false); 6068 result.set_is_optimized(false);
6069 } 6069 }
6070 return result.raw(); 6070 return result.raw();
6071 } 6071 }
6072 6072
hausner 2012/05/08 21:41:01 Remove extra line?
srdjan 2012/05/08 21:51:31 Done.
6073 6073
6074
6074 RawCode* Code::FinalizeCode(const char* name, 6075 RawCode* Code::FinalizeCode(const char* name,
hausner 2012/05/08 21:41:01 Maybe an assert in this function that name is not
srdjan 2012/05/08 21:51:31 Done.
6075 Assembler* assembler, 6076 Assembler* assembler,
6076 Heap::Space space) { 6077 Heap::Space space) {
6077 ASSERT(assembler != NULL); 6078 ASSERT(assembler != NULL);
6078 6079
6079 // Allocate the Instructions object. 6080 // Allocate the Instructions object.
6080 Instructions& instrs = 6081 Instructions& instrs =
6081 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize(), space)); 6082 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize(), space));
6082 6083
6083 // Copy the instructions into the instruction area and apply all fixups. 6084 // Copy the instructions into the instruction area and apply all fixups.
6084 // Embedded pointers are still in handles at this point. 6085 // Embedded pointers are still in handles at this point.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
6143 RawCode* Code::FinalizeCode(const char* name, Assembler* assembler) { 6144 RawCode* Code::FinalizeCode(const char* name, Assembler* assembler) {
6144 return FinalizeCode(name, assembler, Heap::kDartCode); 6145 return FinalizeCode(name, assembler, Heap::kDartCode);
6145 } 6146 }
6146 6147
6147 6148
6148 RawCode* Code::FinalizeStubCode(const char* name, Assembler* assembler) { 6149 RawCode* Code::FinalizeStubCode(const char* name, Assembler* assembler) {
6149 return FinalizeCode(name, assembler, Heap::kStubCode); 6150 return FinalizeCode(name, assembler, Heap::kStubCode);
6150 } 6151 }
6151 6152
6152 6153
6154 RawCode* Code::FinalizeCodeForFunction(const Function& function,
6155 Assembler* assembler) {
6156 // Calling ToFullyQualifiedCString is very expensive, try to avoid it.
6157 if (FLAG_generate_gdb_symbols || (Dart::pprof_symbol_generator() != NULL)) {
6158 return FinalizeCode(function.ToFullyQualifiedCString(),
6159 assembler,
6160 Heap::kDartCode);
6161 } else {
6162 return FinalizeCode("", assembler, Heap::kDartCode);
6163 }
6164 }
6165
hausner 2012/05/08 21:41:01 Save the extra empty line for a rainy day.
srdjan 2012/05/08 21:51:31 Done.
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698