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

Side by Side Diff: src/compiler.h

Issue 10807024: Optimize functions on a second thread. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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
« no previous file with comments | « src/builtins.h ('k') | src/compiler.cc » ('j') | src/compiler.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 21 matching lines...) Expand all
32 #include "ast.h" 32 #include "ast.h"
33 #include "zone.h" 33 #include "zone.h"
34 34
35 namespace v8 { 35 namespace v8 {
36 namespace internal { 36 namespace internal {
37 37
38 class ScriptDataImpl; 38 class ScriptDataImpl;
39 39
40 // CompilationInfo encapsulates some information known at compile time. It 40 // CompilationInfo encapsulates some information known at compile time. It
41 // is constructed based on the resources available at compile-time. 41 // is constructed based on the resources available at compile-time.
42 class CompilationInfo BASE_EMBEDDED { 42 class CompilationInfo {
43 public: 43 public:
44 CompilationInfo(Handle<Script> script, Zone* zone); 44 CompilationInfo(Handle<Script> script, Zone* zone);
45 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone); 45 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone);
46 CompilationInfo(Handle<JSFunction> closure, Zone* zone); 46 CompilationInfo(Handle<JSFunction> closure, Zone* zone);
47 47
48 virtual ~CompilationInfo(); 48 virtual ~CompilationInfo();
49 49
50 Isolate* isolate() { 50 Isolate* isolate() {
51 ASSERT(Isolate::Current() == isolate_); 51 ASSERT(Isolate::Current() == isolate_);
52 return isolate_; 52 return isolate_;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 // Disable all optimization attempts of this info for the rest of the 174 // Disable all optimization attempts of this info for the rest of the
175 // current compilation pipeline. 175 // current compilation pipeline.
176 void AbortOptimization(); 176 void AbortOptimization();
177 177
178 void set_deferred_handles(DeferredHandles* deferred_handles) { 178 void set_deferred_handles(DeferredHandles* deferred_handles) {
179 ASSERT(deferred_handles_ == NULL); 179 ASSERT(deferred_handles_ == NULL);
180 deferred_handles_ = deferred_handles; 180 deferred_handles_ = deferred_handles;
181 } 181 }
182 182
183 void SaveHandles() {
184 SaveHandle(&closure_);
185 SaveHandle(&shared_info_);
186 SaveHandle(&calling_context_);
187 SaveHandle(&script_);
188 }
189
183 private: 190 private:
184 Isolate* isolate_; 191 Isolate* isolate_;
185 192
186 // Compilation mode. 193 // Compilation mode.
187 // BASE is generated by the full codegen, optionally prepared for bailouts. 194 // BASE is generated by the full codegen, optionally prepared for bailouts.
188 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. 195 // OPTIMIZE is optimized code generated by the Hydrogen-based backend.
189 // NONOPT is generated by the full codegen and is not prepared for 196 // NONOPT is generated by the full codegen and is not prepared for
190 // recompilation/bailouts. These functions are never recompiled. 197 // recompilation/bailouts. These functions are never recompiled.
191 enum Mode { 198 enum Mode {
192 BASE, 199 BASE,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // Compilation mode flag and whether deoptimization is allowed. 268 // Compilation mode flag and whether deoptimization is allowed.
262 Mode mode_; 269 Mode mode_;
263 int osr_ast_id_; 270 int osr_ast_id_;
264 271
265 // The zone from which the compilation pipeline working on this 272 // The zone from which the compilation pipeline working on this
266 // CompilationInfo allocates. 273 // CompilationInfo allocates.
267 Zone* zone_; 274 Zone* zone_;
268 275
269 DeferredHandles* deferred_handles_; 276 DeferredHandles* deferred_handles_;
270 277
278 template<typename T>
279 void SaveHandle(Handle<T> *object) {
280 if (!object->is_null()) {
281 Handle<T> handle(*(*object));
282 *object = handle;
283 }
284 }
285
271 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); 286 DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
272 }; 287 };
273 288
274 289
275 // Exactly like a CompilationInfo, except also creates and enters a 290 // Exactly like a CompilationInfo, except also creates and enters a
276 // Zone on construction and deallocates it on exit. 291 // Zone on construction and deallocates it on exit.
277 class CompilationInfoWithZone: public CompilationInfo { 292 class CompilationInfoWithZone: public CompilationInfo {
278 public: 293 public:
279 explicit CompilationInfoWithZone(Handle<Script> script) 294 explicit CompilationInfoWithZone(Handle<Script> script)
280 : CompilationInfo(script, &zone_), 295 : CompilationInfo(script, &zone_),
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, 440 static Handle<SharedFunctionInfo> CompileEval(Handle<String> source,
426 Handle<Context> context, 441 Handle<Context> context,
427 bool is_global, 442 bool is_global,
428 LanguageMode language_mode, 443 LanguageMode language_mode,
429 int scope_position); 444 int scope_position);
430 445
431 // Compile from function info (used for lazy compilation). Returns true on 446 // Compile from function info (used for lazy compilation). Returns true on
432 // success and false if the compilation resulted in a stack overflow. 447 // success and false if the compilation resulted in a stack overflow.
433 static bool CompileLazy(CompilationInfo* info); 448 static bool CompileLazy(CompilationInfo* info);
434 449
450 static void RecompileParallel(Handle<JSFunction> function);
451
435 // Compile a shared function info object (the function is possibly lazily 452 // Compile a shared function info object (the function is possibly lazily
436 // compiled). 453 // compiled).
437 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, 454 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node,
438 Handle<Script> script); 455 Handle<Script> script);
439 456
440 // Set the function info for a newly compiled function. 457 // Set the function info for a newly compiled function.
441 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, 458 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info,
442 FunctionLiteral* lit, 459 FunctionLiteral* lit,
443 bool is_toplevel, 460 bool is_toplevel,
444 Handle<Script> script); 461 Handle<Script> script);
445 462
463 static void InstallOptimizedCode(OptimizingCompiler* info);
464
446 #ifdef ENABLE_DEBUGGER_SUPPORT 465 #ifdef ENABLE_DEBUGGER_SUPPORT
447 static bool MakeCodeForLiveEdit(CompilationInfo* info); 466 static bool MakeCodeForLiveEdit(CompilationInfo* info);
448 #endif 467 #endif
449 468
450 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 469 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
451 CompilationInfo* info, 470 CompilationInfo* info,
452 Handle<SharedFunctionInfo> shared); 471 Handle<SharedFunctionInfo> shared);
453 }; 472 };
454 473
455 474
456 } } // namespace v8::internal 475 } } // namespace v8::internal
457 476
458 #endif // V8_COMPILER_H_ 477 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/compiler.cc » ('j') | src/compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698