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 "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/become.h" | 10 #include "vm/become.h" |
(...skipping 5270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5281 | 5281 |
5282 bool Function::HasBreakpoint() const { | 5282 bool Function::HasBreakpoint() const { |
5283 if (!FLAG_support_debugger) { | 5283 if (!FLAG_support_debugger) { |
5284 return false; | 5284 return false; |
5285 } | 5285 } |
5286 Thread* thread = Thread::Current(); | 5286 Thread* thread = Thread::Current(); |
5287 return thread->isolate()->debugger()->HasBreakpoint(*this, thread->zone()); | 5287 return thread->isolate()->debugger()->HasBreakpoint(*this, thread->zone()); |
5288 } | 5288 } |
5289 | 5289 |
5290 | 5290 |
5291 void Function::InstallOptimizedCode(const Code& code, bool is_osr) const { | 5291 void Function::InstallOptimizedCode(const Code& code) const { |
5292 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); | 5292 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); |
5293 // We may not have previous code if FLAG_precompile is set. | 5293 // We may not have previous code if FLAG_precompile is set. |
5294 // Hot-reload may have already disabled the current code. | 5294 // Hot-reload may have already disabled the current code. |
5295 if (!is_osr && HasCode() && !Code::Handle(CurrentCode()).IsDisabled()) { | 5295 if (HasCode() && !Code::Handle(CurrentCode()).IsDisabled()) { |
5296 Code::Handle(CurrentCode()).DisableDartCode(); | 5296 Code::Handle(CurrentCode()).DisableDartCode(); |
5297 } | 5297 } |
5298 AttachCode(code); | 5298 AttachCode(code); |
5299 } | 5299 } |
5300 | 5300 |
5301 | 5301 |
5302 void Function::SetInstructions(const Code& value) const { | 5302 void Function::SetInstructions(const Code& value) const { |
5303 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); | 5303 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); |
5304 SetInstructionsSafe(value); | 5304 SetInstructionsSafe(value); |
5305 } | 5305 } |
(...skipping 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7321 "FP mismatch while recognizing method %s:" | 7321 "FP mismatch while recognizing method %s:" |
7322 " expecting 0x%08x found 0x%08x\n", | 7322 " expecting 0x%08x found 0x%08x\n", |
7323 ToFullyQualifiedCString(), fp, SourceFingerprint()); | 7323 ToFullyQualifiedCString(), fp, SourceFingerprint()); |
7324 return false; | 7324 return false; |
7325 } | 7325 } |
7326 } | 7326 } |
7327 return true; | 7327 return true; |
7328 } | 7328 } |
7329 | 7329 |
7330 | 7330 |
| 7331 RawCode* Function::EnsureHasCode() const { |
| 7332 if (HasCode()) return CurrentCode(); |
| 7333 Thread* thread = Thread::Current(); |
| 7334 Zone* zone = thread->zone(); |
| 7335 const Object& result = |
| 7336 Object::Handle(zone, Compiler::CompileFunction(thread, *this)); |
| 7337 if (result.IsError()) { |
| 7338 Exceptions::PropagateError(Error::Cast(result)); |
| 7339 UNREACHABLE(); |
| 7340 } |
| 7341 // Compiling in unoptimized mode should never fail if there are no errors. |
| 7342 ASSERT(HasCode()); |
| 7343 ASSERT(unoptimized_code() == result.raw()); |
| 7344 return CurrentCode(); |
| 7345 } |
| 7346 |
| 7347 |
7331 const char* Function::ToCString() const { | 7348 const char* Function::ToCString() const { |
7332 if (IsNull()) { | 7349 if (IsNull()) { |
7333 return "Function: null"; | 7350 return "Function: null"; |
7334 } | 7351 } |
7335 const char* static_str = is_static() ? " static" : ""; | 7352 const char* static_str = is_static() ? " static" : ""; |
7336 const char* abstract_str = is_abstract() ? " abstract" : ""; | 7353 const char* abstract_str = is_abstract() ? " abstract" : ""; |
7337 const char* kind_str = NULL; | 7354 const char* kind_str = NULL; |
7338 const char* const_str = is_const() ? " const" : ""; | 7355 const char* const_str = is_const() ? " const" : ""; |
7339 switch (kind()) { | 7356 switch (kind()) { |
7340 case RawFunction::kRegularFunction: | 7357 case RawFunction::kRegularFunction: |
(...skipping 4428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11769 error = Compiler::CompileAllFunctions(cls); | 11786 error = Compiler::CompileAllFunctions(cls); |
11770 if (!error.IsNull()) { | 11787 if (!error.IsNull()) { |
11771 return error.raw(); | 11788 return error.raw(); |
11772 } | 11789 } |
11773 } | 11790 } |
11774 } | 11791 } |
11775 | 11792 |
11776 // Inner functions get added to the closures array. As part of compilation | 11793 // Inner functions get added to the closures array. As part of compilation |
11777 // more closures can be added to the end of the array. Compile all the | 11794 // more closures can be added to the end of the array. Compile all the |
11778 // closures until we have reached the end of the "worklist". | 11795 // closures until we have reached the end of the "worklist". |
| 11796 Object& result = Object::Handle(zone); |
11779 const GrowableObjectArray& closures = GrowableObjectArray::Handle( | 11797 const GrowableObjectArray& closures = GrowableObjectArray::Handle( |
11780 zone, Isolate::Current()->object_store()->closure_functions()); | 11798 zone, Isolate::Current()->object_store()->closure_functions()); |
11781 Function& func = Function::Handle(zone); | 11799 Function& func = Function::Handle(zone); |
11782 for (int i = 0; i < closures.Length(); i++) { | 11800 for (int i = 0; i < closures.Length(); i++) { |
11783 func ^= closures.At(i); | 11801 func ^= closures.At(i); |
11784 if (!func.HasCode()) { | 11802 if (!func.HasCode()) { |
11785 error = Compiler::CompileFunction(thread, func); | 11803 result = Compiler::CompileFunction(thread, func); |
11786 if (!error.IsNull()) { | 11804 if (result.IsError()) { |
11787 return error.raw(); | 11805 return Error::Cast(result).raw(); |
11788 } | 11806 } |
11789 func.ClearICDataArray(); | 11807 func.ClearICDataArray(); |
11790 func.ClearCode(); | 11808 func.ClearCode(); |
11791 } | 11809 } |
11792 } | 11810 } |
11793 return error.raw(); | 11811 return Error::null(); |
11794 } | 11812 } |
11795 | 11813 |
11796 | 11814 |
11797 RawError* Library::ParseAll(Thread* thread) { | 11815 RawError* Library::ParseAll(Thread* thread) { |
11798 Zone* zone = thread->zone(); | 11816 Zone* zone = thread->zone(); |
11799 Error& error = Error::Handle(zone); | 11817 Error& error = Error::Handle(zone); |
11800 Isolate* isolate = thread->isolate(); | 11818 Isolate* isolate = thread->isolate(); |
11801 const GrowableObjectArray& libs = | 11819 const GrowableObjectArray& libs = |
11802 GrowableObjectArray::Handle(isolate->object_store()->libraries()); | 11820 GrowableObjectArray::Handle(isolate->object_store()->libraries()); |
11803 Library& lib = Library::Handle(zone); | 11821 Library& lib = Library::Handle(zone); |
(...skipping 11285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23089 return UserTag::null(); | 23107 return UserTag::null(); |
23090 } | 23108 } |
23091 | 23109 |
23092 | 23110 |
23093 const char* UserTag::ToCString() const { | 23111 const char* UserTag::ToCString() const { |
23094 const String& tag_label = String::Handle(label()); | 23112 const String& tag_label = String::Handle(label()); |
23095 return tag_label.ToCString(); | 23113 return tag_label.ToCString(); |
23096 } | 23114 } |
23097 | 23115 |
23098 } // namespace dart | 23116 } // namespace dart |
OLD | NEW |