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

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

Issue 1052563003: VM: Add infrastructure to support deferred generation of unoptimized code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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/compiler.h" 5 #include "vm/compiler.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 8
9 #include "vm/ast_printer.h" 9 #include "vm/ast_printer.h"
10 #include "vm/block_scheduler.h" 10 #include "vm/block_scheduler.h"
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 intptr_t osr_id) { 966 intptr_t osr_id) {
967 Thread* volatile thread = Thread::Current(); 967 Thread* volatile thread = Thread::Current();
968 Isolate* volatile isolate = thread->isolate(); 968 Isolate* volatile isolate = thread->isolate();
969 StackZone stack_zone(isolate); 969 StackZone stack_zone(isolate);
970 Zone* volatile zone = stack_zone.GetZone(); 970 Zone* volatile zone = stack_zone.GetZone();
971 LongJumpScope jump; 971 LongJumpScope jump;
972 if (setjmp(*jump.Set()) == 0) { 972 if (setjmp(*jump.Set()) == 0) {
973 TIMERSCOPE(isolate, time_compilation); 973 TIMERSCOPE(isolate, time_compilation);
974 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); 974 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time");
975 per_compile_timer.Start(); 975 per_compile_timer.Start();
976
976 ParsedFunction* parsed_function = new(zone) ParsedFunction( 977 ParsedFunction* parsed_function = new(zone) ParsedFunction(
977 thread, Function::ZoneHandle(zone, function.raw())); 978 thread, Function::ZoneHandle(zone, function.raw()));
978 if (FLAG_trace_compiler) { 979 if (FLAG_trace_compiler) {
979 ISL_Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", 980 ISL_Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n",
980 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), 981 (osr_id == Isolate::kNoDeoptId ? "" : "osr "),
981 (optimized ? "optimized " : ""), 982 (optimized ? "optimized " : ""),
982 function.ToFullyQualifiedCString(), 983 function.ToFullyQualifiedCString(),
983 function.token_pos(), 984 function.token_pos(),
984 (function.end_token_pos() - function.token_pos())); 985 (function.end_token_pos() - function.token_pos()));
985 } 986 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 1046
1046 RawError* Compiler::CompileFunction(Thread* thread, 1047 RawError* Compiler::CompileFunction(Thread* thread,
1047 const Function& function) { 1048 const Function& function) {
1048 VMTagScope tagScope(thread->isolate(), VMTag::kCompileUnoptimizedTagId); 1049 VMTagScope tagScope(thread->isolate(), VMTag::kCompileUnoptimizedTagId);
1049 CompilationPipeline* pipeline = 1050 CompilationPipeline* pipeline =
1050 CompilationPipeline::New(thread->zone(), function); 1051 CompilationPipeline::New(thread->zone(), function);
1051 return CompileFunctionHelper(pipeline, function, false, Isolate::kNoDeoptId); 1052 return CompileFunctionHelper(pipeline, function, false, Isolate::kNoDeoptId);
1052 } 1053 }
1053 1054
1054 1055
1056 void Compiler::EnsureUnoptimizedCode(Thread* thread,
1057 const Function& function) {
1058 if (function.unoptimized_code() != Object::null()) {
1059 return;
1060 }
1061 Code& original_code = Code::ZoneHandle();
srdjan 2015/04/02 17:43:40 pass thread->zone() to it.
Florian Schneider 2015/04/07 09:07:57 Done.
1062 if (function.HasCode()) {
1063 original_code = function.CurrentCode();
1064 }
1065 CompilationPipeline* pipeline =
1066 CompilationPipeline::New(thread->zone(), function);
1067 const Error& error = Error::Handle(
1068 CompileFunctionHelper(pipeline, function, false, Isolate::kNoDeoptId));
1069 if (!error.IsNull()) {
1070 Exceptions::PropagateError(error);
1071 }
1072 if (!original_code.IsNull() &&
Ivan Posva 2015/04/02 17:14:00 This logic here is really hard to follow. Please e
Florian Schneider 2015/04/07 09:07:57 Done.
1073 (original_code.raw() != function.CurrentCode())) {
1074 function.AttachCode(original_code);
1075 }
1076 ASSERT(function.unoptimized_code() != Object::null());
1077 if (FLAG_trace_compiler) {
1078 ISL_Print("Ensure unoptimized code for %s\n", function.ToCString());
1079 }
1080 }
1081
1082
1055 RawError* Compiler::CompileOptimizedFunction(Thread* thread, 1083 RawError* Compiler::CompileOptimizedFunction(Thread* thread,
1056 const Function& function, 1084 const Function& function,
1057 intptr_t osr_id) { 1085 intptr_t osr_id) {
1058 VMTagScope tagScope(thread->isolate(), VMTag::kCompileOptimizedTagId); 1086 VMTagScope tagScope(thread->isolate(), VMTag::kCompileOptimizedTagId);
1059 CompilationPipeline* pipeline = 1087 CompilationPipeline* pipeline =
1060 CompilationPipeline::New(thread->zone(), function); 1088 CompilationPipeline::New(thread->zone(), function);
1061 return CompileFunctionHelper(pipeline, function, true, osr_id); 1089 return CompileFunctionHelper(pipeline, function, true, osr_id);
1062 } 1090 }
1063 1091
1064 1092
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 const Object& result = 1259 const Object& result =
1232 PassiveObject::Handle(isolate->object_store()->sticky_error()); 1260 PassiveObject::Handle(isolate->object_store()->sticky_error());
1233 isolate->object_store()->clear_sticky_error(); 1261 isolate->object_store()->clear_sticky_error();
1234 return result.raw(); 1262 return result.raw();
1235 } 1263 }
1236 UNREACHABLE(); 1264 UNREACHABLE();
1237 return Object::null(); 1265 return Object::null();
1238 } 1266 }
1239 1267
1240 } // namespace dart 1268 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698