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

Unified Diff: runtime/vm/object.cc

Issue 2781483005: Improve internal compiler API so that OSR code is never installed on function. (Closed)
Patch Set: cosmetics Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/precompiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 807f7c30ddfe922632dc989c28321bb00fef0667..502e747371cf65c5ea75010f1ea648d27e5904a4 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -5288,11 +5288,11 @@ bool Function::HasBreakpoint() const {
}
-void Function::InstallOptimizedCode(const Code& code, bool is_osr) const {
+void Function::InstallOptimizedCode(const Code& code) const {
DEBUG_ASSERT(IsMutatorOrAtSafepoint());
// We may not have previous code if FLAG_precompile is set.
// Hot-reload may have already disabled the current code.
- if (!is_osr && HasCode() && !Code::Handle(CurrentCode()).IsDisabled()) {
+ if (HasCode() && !Code::Handle(CurrentCode()).IsDisabled()) {
Code::Handle(CurrentCode()).DisableDartCode();
}
AttachCode(code);
@@ -7328,6 +7328,23 @@ bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const {
}
+RawCode* Function::EnsureHasCode() const {
+ if (HasCode()) return CurrentCode();
+ Thread* thread = Thread::Current();
+ Zone* zone = thread->zone();
+ const Object& result =
+ Object::Handle(zone, Compiler::CompileFunction(thread, *this));
+ if (result.IsError()) {
+ Exceptions::PropagateError(Error::Cast(result));
+ UNREACHABLE();
+ }
+ // Compiling in unoptimized mode should never fail if there are no errors.
+ ASSERT(HasCode());
+ ASSERT(unoptimized_code() == result.raw());
+ return CurrentCode();
+}
+
+
const char* Function::ToCString() const {
if (IsNull()) {
return "Function: null";
@@ -11776,21 +11793,22 @@ RawError* Library::CompileAll() {
// Inner functions get added to the closures array. As part of compilation
// more closures can be added to the end of the array. Compile all the
// closures until we have reached the end of the "worklist".
+ Object& result = Object::Handle(zone);
const GrowableObjectArray& closures = GrowableObjectArray::Handle(
zone, Isolate::Current()->object_store()->closure_functions());
Function& func = Function::Handle(zone);
for (int i = 0; i < closures.Length(); i++) {
func ^= closures.At(i);
if (!func.HasCode()) {
- error = Compiler::CompileFunction(thread, func);
- if (!error.IsNull()) {
- return error.raw();
+ result = Compiler::CompileFunction(thread, func);
+ if (result.IsError()) {
+ return Error::Cast(result).raw();
}
func.ClearICDataArray();
func.ClearCode();
}
}
- return error.raw();
+ return Error::null();
}
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/precompiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698