| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/precompiler.h" | 5 #include "vm/precompiler.h" |
| 6 | 6 |
| 7 #include "vm/aot_optimizer.h" | 7 #include "vm/aot_optimizer.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 10 #include "vm/branch_optimizer.h" | 10 #include "vm/branch_optimizer.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 | 214 |
| 215 TypeRangeCache::~TypeRangeCache() { | 215 TypeRangeCache::~TypeRangeCache() { |
| 216 ASSERT(precompiler_->type_range_cache() == this); | 216 ASSERT(precompiler_->type_range_cache() == this); |
| 217 precompiler_->set_type_range_cache(NULL); | 217 precompiler_->set_type_range_cache(NULL); |
| 218 } | 218 } |
| 219 | 219 |
| 220 | 220 |
| 221 RawError* Precompiler::CompileAll( | 221 RawError* Precompiler::CompileAll( |
| 222 Dart_QualifiedFunctionName embedder_entry_points[], | 222 Dart_QualifiedFunctionName embedder_entry_points[], |
| 223 bool reset_fields, | |
| 224 uint8_t* jit_feedback, | 223 uint8_t* jit_feedback, |
| 225 intptr_t jit_feedback_length) { | 224 intptr_t jit_feedback_length) { |
| 226 LongJumpScope jump; | 225 LongJumpScope jump; |
| 227 if (setjmp(*jump.Set()) == 0) { | 226 if (setjmp(*jump.Set()) == 0) { |
| 228 Precompiler precompiler(Thread::Current(), reset_fields); | 227 Precompiler precompiler(Thread::Current()); |
| 229 precompiler.LoadFeedback(jit_feedback, jit_feedback_length); | 228 precompiler.LoadFeedback(jit_feedback, jit_feedback_length); |
| 230 precompiler.DoCompileAll(embedder_entry_points); | 229 precompiler.DoCompileAll(embedder_entry_points); |
| 231 return Error::null(); | 230 return Error::null(); |
| 232 } else { | 231 } else { |
| 233 Thread* thread = Thread::Current(); | 232 Thread* thread = Thread::Current(); |
| 234 const Error& error = Error::Handle(thread->sticky_error()); | 233 const Error& error = Error::Handle(thread->sticky_error()); |
| 235 thread->clear_sticky_error(); | 234 thread->clear_sticky_error(); |
| 236 return error.raw(); | 235 return error.raw(); |
| 237 } | 236 } |
| 238 } | 237 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 THR_Print("Type check for %s is cid range [%" Pd ", %" Pd "]\n", | 324 THR_Print("Type check for %s is cid range [%" Pd ", %" Pd "]\n", |
| 326 type.ToCString(), *lower_limit, *upper_limit); | 325 type.ToCString(), *lower_limit, *upper_limit); |
| 327 } | 326 } |
| 328 | 327 |
| 329 lower_limits_[type_cid] = *lower_limit; | 328 lower_limits_[type_cid] = *lower_limit; |
| 330 upper_limits_[type_cid] = *upper_limit; | 329 upper_limits_[type_cid] = *upper_limit; |
| 331 return true; | 330 return true; |
| 332 } | 331 } |
| 333 | 332 |
| 334 | 333 |
| 335 Precompiler::Precompiler(Thread* thread, bool reset_fields) | 334 Precompiler::Precompiler(Thread* thread) |
| 336 : thread_(thread), | 335 : thread_(thread), |
| 337 zone_(NULL), | 336 zone_(NULL), |
| 338 isolate_(thread->isolate()), | 337 isolate_(thread->isolate()), |
| 339 reset_fields_(reset_fields), | |
| 340 jit_feedback_(NULL), | 338 jit_feedback_(NULL), |
| 341 changed_(false), | 339 changed_(false), |
| 342 function_count_(0), | 340 function_count_(0), |
| 343 class_count_(0), | 341 class_count_(0), |
| 344 selector_count_(0), | 342 selector_count_(0), |
| 345 dropped_function_count_(0), | 343 dropped_function_count_(0), |
| 346 dropped_field_count_(0), | 344 dropped_field_count_(0), |
| 347 dropped_class_count_(0), | 345 dropped_class_count_(0), |
| 348 dropped_typearg_count_(0), | 346 dropped_typearg_count_(0), |
| 349 dropped_type_count_(0), | 347 dropped_type_count_(0), |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 {"dart:isolate", "::", "_getIsolateScheduleImmediateClosure"}, | 677 {"dart:isolate", "::", "_getIsolateScheduleImmediateClosure"}, |
| 680 {"dart:isolate", "::", "_setupHooks"}, | 678 {"dart:isolate", "::", "_setupHooks"}, |
| 681 {"dart:isolate", "::", "_startMainIsolate"}, | 679 {"dart:isolate", "::", "_startMainIsolate"}, |
| 682 {"dart:isolate", "::", "_startIsolate"}, | 680 {"dart:isolate", "::", "_startIsolate"}, |
| 683 {"dart:isolate", "_RawReceivePortImpl", "_handleMessage"}, | 681 {"dart:isolate", "_RawReceivePortImpl", "_handleMessage"}, |
| 684 {"dart:isolate", "_RawReceivePortImpl", "_lookupHandler"}, | 682 {"dart:isolate", "_RawReceivePortImpl", "_lookupHandler"}, |
| 685 {"dart:isolate", "_SendPortImpl", "send"}, | 683 {"dart:isolate", "_SendPortImpl", "send"}, |
| 686 {"dart:typed_data", "ByteData", "ByteData."}, | 684 {"dart:typed_data", "ByteData", "ByteData."}, |
| 687 {"dart:typed_data", "ByteData", "ByteData._view"}, | 685 {"dart:typed_data", "ByteData", "ByteData._view"}, |
| 688 {"dart:typed_data", "_ByteBuffer", "_ByteBuffer._New"}, | 686 {"dart:typed_data", "_ByteBuffer", "_ByteBuffer._New"}, |
| 687 #if !defined(PRODUCT) |
| 689 {"dart:_vmservice", "::", "_registerIsolate"}, | 688 {"dart:_vmservice", "::", "_registerIsolate"}, |
| 690 {"dart:_vmservice", "::", "boot"}, | 689 {"dart:_vmservice", "::", "boot"}, |
| 691 #if !defined(PRODUCT) | |
| 692 {"dart:developer", "Metrics", "_printMetrics"}, | 690 {"dart:developer", "Metrics", "_printMetrics"}, |
| 693 {"dart:developer", "::", "_runExtension"}, | 691 {"dart:developer", "::", "_runExtension"}, |
| 694 {"dart:isolate", "::", "_runPendingImmediateCallback"}, | 692 {"dart:isolate", "::", "_runPendingImmediateCallback"}, |
| 695 #endif // !PRODUCT | 693 #endif // !PRODUCT |
| 696 // Fields | 694 // Fields |
| 697 {"dart:core", "Error", "_stackTrace"}, | 695 {"dart:core", "Error", "_stackTrace"}, |
| 698 {"dart:math", "_Random", "_state"}, | 696 {"dart:math", "_Random", "_state"}, |
| 699 {NULL, NULL, NULL} // Must be terminated with NULL entries. | 697 {NULL, NULL, NULL} // Must be terminated with NULL entries. |
| 700 }; | 698 }; |
| 701 | 699 |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 if (field.is_static()) { | 1175 if (field.is_static()) { |
| 1178 const Object& value = Object::Handle(Z, field.StaticValue()); | 1176 const Object& value = Object::Handle(Z, field.StaticValue()); |
| 1179 if (value.IsInstance()) { | 1177 if (value.IsInstance()) { |
| 1180 AddConstObject(Instance::Cast(value)); | 1178 AddConstObject(Instance::Cast(value)); |
| 1181 } | 1179 } |
| 1182 | 1180 |
| 1183 if (field.has_initializer()) { | 1181 if (field.has_initializer()) { |
| 1184 // Should not be in the middle of initialization while precompiling. | 1182 // Should not be in the middle of initialization while precompiling. |
| 1185 ASSERT(value.raw() != Object::transition_sentinel().raw()); | 1183 ASSERT(value.raw() != Object::transition_sentinel().raw()); |
| 1186 | 1184 |
| 1187 const bool is_initialized = value.raw() != Object::sentinel().raw(); | |
| 1188 if (is_initialized && !reset_fields_) return; | |
| 1189 | |
| 1190 if (!field.HasPrecompiledInitializer() || | 1185 if (!field.HasPrecompiledInitializer() || |
| 1191 !Function::Handle(Z, field.PrecompiledInitializer()).HasCode()) { | 1186 !Function::Handle(Z, field.PrecompiledInitializer()).HasCode()) { |
| 1192 if (FLAG_trace_precompiler) { | 1187 if (FLAG_trace_precompiler) { |
| 1193 THR_Print("Precompiling initializer for %s\n", field.ToCString()); | 1188 THR_Print("Precompiling initializer for %s\n", field.ToCString()); |
| 1194 } | 1189 } |
| 1195 ASSERT(Dart::snapshot_kind() != Snapshot::kAppAOT); | 1190 ASSERT(Dart::snapshot_kind() != Snapshot::kAppAOT); |
| 1196 const Function& initializer = Function::Handle( | 1191 const Function& initializer = Function::Handle( |
| 1197 Z, CompileStaticInitializer(field, /* compute_type = */ true)); | 1192 Z, CompileStaticInitializer(field, /* compute_type = */ true)); |
| 1198 ASSERT(!initializer.IsNull()); | 1193 ASSERT(!initializer.IsNull()); |
| 1199 field.SetPrecompiledInitializer(initializer); | 1194 field.SetPrecompiledInitializer(initializer); |
| (...skipping 2462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3662 | 3657 |
| 3663 ASSERT(FLAG_precompiled_mode); | 3658 ASSERT(FLAG_precompiled_mode); |
| 3664 const bool optimized = function.IsOptimizable(); // False for natives. | 3659 const bool optimized = function.IsOptimizable(); // False for natives. |
| 3665 DartPrecompilationPipeline pipeline(zone, field_type_map); | 3660 DartPrecompilationPipeline pipeline(zone, field_type_map); |
| 3666 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); | 3661 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); |
| 3667 } | 3662 } |
| 3668 | 3663 |
| 3669 #endif // DART_PRECOMPILER | 3664 #endif // DART_PRECOMPILER |
| 3670 | 3665 |
| 3671 } // namespace dart | 3666 } // namespace dart |
| OLD | NEW |