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

Side by Side Diff: src/compiler.h

Issue 10700188: Introduce an OptimizingCompiler class, responsible for maintaining the state needed to run Cranksha… (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 | « no previous file | 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 ~CompilationHandleScope() { 305 ~CompilationHandleScope() {
306 info_->set_deferred_handles(deferred_.Detach()); 306 info_->set_deferred_handles(deferred_.Detach());
307 } 307 }
308 308
309 private: 309 private:
310 DeferredHandleScope deferred_; 310 DeferredHandleScope deferred_;
311 CompilationInfo* info_; 311 CompilationInfo* info_;
312 }; 312 };
313 313
314 314
315 class HGraph;
316 class HGraphBuilder;
317 class LChunk;
318
319 // A helper class that calls the three phases in Crankshaft and keeps
danno 2012/07/16 12:19:09 nit: compilation phases maybe you should list what
sanjoy 2012/07/16 13:46:46 Done.
320 // track of its state.
321 class OptimizingCompiler: public ZoneObject {
322 public:
323 explicit OptimizingCompiler(CompilationInfo* info)
324 : info_(info),
325 oracle_(NULL),
326 graph_builder_(NULL),
327 graph_(NULL),
328 chunk_(NULL),
329 total_time_taken_(0),
330 is_inline_bailout_(false),
331 last_status_(FAILED) { }
332
333 enum Status {
334 FAILED, BAILED_OUT, SUCCEEDED
335 };
336
337 Status CreateHGraph() {
danno 2012/07/16 12:19:09 Just call this CreateGraph()
sanjoy 2012/07/16 13:46:46 Done.
338 last_status_ = InnerCreateHGraph();
339 return last_status_;
340 }
341 Status OptimizeHGraph() {
danno 2012/07/16 12:19:09 OptimizeGraph
sanjoy 2012/07/16 13:46:46 Done.
342 last_status_ = InnerOptimizeHGraph();
343 return last_status_;
344 }
345 Status GenerateAndInstallCode() {
346 last_status_ = InnerGenerateAndInstallCode();
347 if (last_status_ == SUCCEEDED) RecordOptimizationStats();
348 return last_status_;
349 }
350
351 Status last_status() const { return last_status_; }
352 CompilationInfo* info() const { return info_; }
353
354 private:
355 CompilationInfo* info_;
356 TypeFeedbackOracle* oracle_;
357 HGraphBuilder* graph_builder_;
358 HGraph* graph_;
359 LChunk* chunk_;
360 int64_t total_time_taken_;
361 bool is_inline_bailout_;
362 Status last_status_;
363
364 Status InnerCreateHGraph();
danno 2012/07/16 12:19:09 I don't understand why you need these "Inner" meth
sanjoy 2012/07/16 13:46:46 I wanted to have a central place to set last_statu
365 Status InnerOptimizeHGraph();
366 Status InnerGenerateAndInstallCode();
367
368 void RecordOptimizationStats();
369
370 void AbortCrankshaft() {
371 info_->AbortOptimization();
372 if (!is_inline_bailout_) {
373 // Mark the shared code as unoptimizable unless it was an inlined
374 // function that bailed out.
375 info_->shared_info()->DisableOptimization();
376 }
377 }
378
379 struct Timer {
380 explicit Timer(OptimizingCompiler* compiler)
381 : compiler_(compiler),
382 start_(OS::Ticks()) { }
383
384 ~Timer() {
385 compiler_->total_time_taken_ += (OS::Ticks() - start_);
danno 2012/07/16 12:19:09 Perhaps divide this up into three counters, one fo
sanjoy 2012/07/16 13:46:46 Done.
386 }
387
388 OptimizingCompiler* compiler_;
389 int64_t start_;
390 };
391 };
392
393
315 // The V8 compiler 394 // The V8 compiler
316 // 395 //
317 // General strategy: Source code is translated into an anonymous function w/o 396 // General strategy: Source code is translated into an anonymous function w/o
318 // parameters which then can be executed. If the source code contains other 397 // parameters which then can be executed. If the source code contains other
319 // functions, they will be compiled and allocated as part of the compilation 398 // functions, they will be compiled and allocated as part of the compilation
320 // of the source code. 399 // of the source code.
321 400
322 // Please note this interface returns shared function infos. This means you 401 // Please note this interface returns shared function infos. This means you
323 // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a 402 // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a
324 // real function with a context. 403 // real function with a context.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 455
377 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 456 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
378 CompilationInfo* info, 457 CompilationInfo* info,
379 Handle<SharedFunctionInfo> shared); 458 Handle<SharedFunctionInfo> shared);
380 }; 459 };
381 460
382 461
383 } } // namespace v8::internal 462 } } // namespace v8::internal
384 463
385 #endif // V8_COMPILER_H_ 464 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | src/compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698