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

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: Review. 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') | no next file with comments »
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 compilation phases in
320 // Crankshaft and keeps track of its state. The three phases
321 // CreateGraph, OptimizeGraph and GenerateAndInstallCode can either
322 // fail, bail-out to the full code generator or succeed. Apart from
323 // their return value, the status of the phase last run can be checked
324 // using last_status().
325 class OptimizingCompiler: public ZoneObject {
326 public:
327 explicit OptimizingCompiler(CompilationInfo* info)
328 : info_(info),
329 oracle_(NULL),
330 graph_builder_(NULL),
331 graph_(NULL),
332 chunk_(NULL),
333 time_taken_to_create_graph_(0),
334 time_taken_to_optimize_(0),
335 time_taken_to_codegen_(0),
336 last_status_(FAILED) { }
337
338 enum Status {
339 FAILED, BAILED_OUT, SUCCEEDED
340 };
341
342 MUST_USE_RESULT Status CreateGraph();
343 MUST_USE_RESULT Status OptimizeGraph();
344 MUST_USE_RESULT Status GenerateAndInstallCode();
345
346 Status last_status() const { return last_status_; }
347 CompilationInfo* info() const { return info_; }
348
349 private:
350 CompilationInfo* info_;
351 TypeFeedbackOracle* oracle_;
352 HGraphBuilder* graph_builder_;
353 HGraph* graph_;
354 LChunk* chunk_;
355 int64_t time_taken_to_create_graph_;
356 int64_t time_taken_to_optimize_;
357 int64_t time_taken_to_codegen_;
358 Status last_status_;
359
360 MUST_USE_RESULT Status SetLastStatus(Status status) {
361 last_status_ = status;
362 return last_status_;
363 }
364 void RecordOptimizationStats();
365 MUST_USE_RESULT Status AbortOptimization() {
366 info_->AbortOptimization();
367 info_->shared_info()->DisableOptimization();
368 return SetLastStatus(BAILED_OUT);
369 }
370
371 struct Timer {
372 Timer(OptimizingCompiler* compiler, int64_t* location)
373 : compiler_(compiler),
374 start_(OS::Ticks()),
375 location_(location) { }
376
377 ~Timer() {
378 *location_ += (OS::Ticks() - start_);
379 }
380
381 OptimizingCompiler* compiler_;
382 int64_t start_;
383 int64_t* location_;
384 };
385 };
386
387
315 // The V8 compiler 388 // The V8 compiler
316 // 389 //
317 // General strategy: Source code is translated into an anonymous function w/o 390 // 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 391 // 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 392 // functions, they will be compiled and allocated as part of the compilation
320 // of the source code. 393 // of the source code.
321 394
322 // Please note this interface returns shared function infos. This means you 395 // Please note this interface returns shared function infos. This means you
323 // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a 396 // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a
324 // real function with a context. 397 // real function with a context.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 449
377 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 450 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
378 CompilationInfo* info, 451 CompilationInfo* info,
379 Handle<SharedFunctionInfo> shared); 452 Handle<SharedFunctionInfo> shared);
380 }; 453 };
381 454
382 455
383 } } // namespace v8::internal 456 } } // namespace v8::internal
384 457
385 #endif // V8_COMPILER_H_ 458 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698