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

Side by Side Diff: src/compiler.cc

Issue 11414262: Revert 13105: "Enable stub generation using Hydrogen/Lithium." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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/compiler.h ('k') | src/deoptimizer.h » ('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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "vm-state-inl.h" 48 #include "vm-state-inl.h"
49 49
50 namespace v8 { 50 namespace v8 {
51 namespace internal { 51 namespace internal {
52 52
53 53
54 CompilationInfo::CompilationInfo(Handle<Script> script, Zone* zone) 54 CompilationInfo::CompilationInfo(Handle<Script> script, Zone* zone)
55 : flags_(LanguageModeField::encode(CLASSIC_MODE)), 55 : flags_(LanguageModeField::encode(CLASSIC_MODE)),
56 script_(script), 56 script_(script),
57 osr_ast_id_(BailoutId::None()) { 57 osr_ast_id_(BailoutId::None()) {
58 Initialize(script->GetIsolate(), BASE, zone); 58 Initialize(zone);
59 } 59 }
60 60
61 61
62 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info, 62 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info,
63 Zone* zone) 63 Zone* zone)
64 : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)), 64 : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)),
65 shared_info_(shared_info), 65 shared_info_(shared_info),
66 script_(Handle<Script>(Script::cast(shared_info->script()))), 66 script_(Handle<Script>(Script::cast(shared_info->script()))),
67 osr_ast_id_(BailoutId::None()) { 67 osr_ast_id_(BailoutId::None()) {
68 Initialize(script_->GetIsolate(), BASE, zone); 68 Initialize(zone);
69 } 69 }
70 70
71 71
72 CompilationInfo::CompilationInfo(Handle<JSFunction> closure, Zone* zone) 72 CompilationInfo::CompilationInfo(Handle<JSFunction> closure, Zone* zone)
73 : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)), 73 : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)),
74 closure_(closure), 74 closure_(closure),
75 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), 75 shared_info_(Handle<SharedFunctionInfo>(closure->shared())),
76 script_(Handle<Script>(Script::cast(shared_info_->script()))), 76 script_(Handle<Script>(Script::cast(shared_info_->script()))),
77 context_(closure->context()), 77 context_(closure->context()),
78 osr_ast_id_(BailoutId::None()) { 78 osr_ast_id_(BailoutId::None()) {
79 Initialize(script_->GetIsolate(), BASE, zone); 79 Initialize(zone);
80 } 80 }
81 81
82 82
83 CompilationInfo::CompilationInfo(HydrogenCodeStub* stub, 83 void CompilationInfo::Initialize(Zone* zone) {
84 Isolate* isolate, Zone* zone) 84 isolate_ = script_->GetIsolate();
85 : flags_(LanguageModeField::encode(CLASSIC_MODE) |
86 IsLazy::encode(true)),
87 osr_ast_id_(BailoutId::None()) {
88 Initialize(isolate, STUB, zone);
89 code_stub_ = stub;
90 }
91
92
93 void CompilationInfo::Initialize(Isolate* isolate, Mode mode, Zone* zone) {
94 isolate_ = isolate;
95 function_ = NULL; 85 function_ = NULL;
96 scope_ = NULL; 86 scope_ = NULL;
97 global_scope_ = NULL; 87 global_scope_ = NULL;
98 extension_ = NULL; 88 extension_ = NULL;
99 pre_parse_data_ = NULL; 89 pre_parse_data_ = NULL;
100 zone_ = zone; 90 zone_ = zone;
101 deferred_handles_ = NULL; 91 deferred_handles_ = NULL;
102 code_stub_ = NULL;
103 prologue_offset_ = kPrologueOffsetNotSet; 92 prologue_offset_ = kPrologueOffsetNotSet;
104 if (mode == STUB) { 93 mode_ = V8::UseCrankshaft() ? BASE : NONOPT;
105 mode_ = STUB;
106 return;
107 }
108 mode_ = V8::UseCrankshaft() ? mode : NONOPT;
109 if (script_->type()->value() == Script::TYPE_NATIVE) { 94 if (script_->type()->value() == Script::TYPE_NATIVE) {
110 MarkAsNative(); 95 MarkAsNative();
111 } 96 }
112 if (!shared_info_.is_null()) { 97 if (!shared_info_.is_null()) {
113 ASSERT(language_mode() == CLASSIC_MODE); 98 ASSERT(language_mode() == CLASSIC_MODE);
114 SetLanguageMode(shared_info_->language_mode()); 99 SetLanguageMode(shared_info_->language_mode());
115 } 100 }
116 set_bailout_reason("unknown"); 101 set_bailout_reason("unknown");
117 } 102 }
118 103
119 104
120 CompilationInfo::~CompilationInfo() { 105 CompilationInfo::~CompilationInfo() {
121 delete deferred_handles_; 106 delete deferred_handles_;
122 } 107 }
123 108
124 109
125 int CompilationInfo::num_parameters() const {
126 if (IsStub()) {
127 return 0;
128 } else {
129 return scope()->num_parameters();
130 }
131 }
132
133
134 int CompilationInfo::num_heap_slots() const {
135 if (IsStub()) {
136 return 0;
137 } else {
138 return scope()->num_heap_slots();
139 }
140 }
141
142
143 Code::Flags CompilationInfo::flags() const {
144 if (IsStub()) {
145 return Code::ComputeFlags(Code::COMPILED_STUB);
146 } else {
147 return Code::ComputeFlags(Code::OPTIMIZED_FUNCTION);
148 }
149 }
150
151
152 // Disable optimization for the rest of the compilation pipeline. 110 // Disable optimization for the rest of the compilation pipeline.
153 void CompilationInfo::DisableOptimization() { 111 void CompilationInfo::DisableOptimization() {
154 bool is_optimizable_closure = 112 bool is_optimizable_closure =
155 FLAG_optimize_closures && 113 FLAG_optimize_closures &&
156 closure_.is_null() && 114 closure_.is_null() &&
157 !scope_->HasTrivialOuterContext() && 115 !scope_->HasTrivialOuterContext() &&
158 !scope_->outer_scope_calls_non_strict_eval() && 116 !scope_->outer_scope_calls_non_strict_eval() &&
159 !scope_->inside_with(); 117 !scope_->inside_with();
160 SetMode(is_optimizable_closure ? BASE : NONOPT); 118 SetMode(is_optimizable_closure ? BASE : NONOPT);
161 } 119 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // optimizations. When using the always_opt flag we disregard the 310 // optimizations. When using the always_opt flag we disregard the
353 // optimizable marker in the code object and optimize anyway. This 311 // optimizable marker in the code object and optimize anyway. This
354 // is safe as long as the unoptimized code has deoptimization 312 // is safe as long as the unoptimized code has deoptimization
355 // support. 313 // support.
356 ASSERT(FLAG_always_opt || code->optimizable()); 314 ASSERT(FLAG_always_opt || code->optimizable());
357 ASSERT(info()->shared_info()->has_deoptimization_support()); 315 ASSERT(info()->shared_info()->has_deoptimization_support());
358 316
359 if (FLAG_trace_hydrogen) { 317 if (FLAG_trace_hydrogen) {
360 PrintF("-----------------------------------------------------------\n"); 318 PrintF("-----------------------------------------------------------\n");
361 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); 319 PrintF("Compiling method %s using hydrogen\n", *name->ToCString());
362 HTracer::Instance()->TraceCompilation(info()); 320 HTracer::Instance()->TraceCompilation(info()->function());
363 } 321 }
364 Handle<Context> native_context( 322 Handle<Context> native_context(
365 info()->closure()->context()->native_context()); 323 info()->closure()->context()->native_context());
366 oracle_ = new(info()->zone()) TypeFeedbackOracle( 324 oracle_ = new(info()->zone()) TypeFeedbackOracle(
367 code, native_context, info()->isolate(), info()->zone()); 325 code, native_context, info()->isolate(), info()->zone());
368 graph_builder_ = new(info()->zone()) HOptimizedGraphBuilder(info(), oracle_); 326 graph_builder_ = new(info()->zone()) HGraphBuilder(info(), oracle_);
369 327
370 Timer t(this, &time_taken_to_create_graph_); 328 Timer t(this, &time_taken_to_create_graph_);
371 graph_ = graph_builder_->CreateGraph(); 329 graph_ = graph_builder_->CreateGraph();
372 330
373 if (info()->isolate()->has_pending_exception()) { 331 if (info()->isolate()->has_pending_exception()) {
374 info()->SetCode(Handle<Code>::null()); 332 info()->SetCode(Handle<Code>::null());
375 return SetLastStatus(FAILED); 333 return SetLastStatus(FAILED);
376 } 334 }
377 335
378 // The function being compiled may have bailed out due to an inline 336 // The function being compiled may have bailed out due to an inline
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 return SetLastStatus(SUCCEEDED); 369 return SetLastStatus(SUCCEEDED);
412 } 370 }
413 371
414 372
415 OptimizingCompiler::Status OptimizingCompiler::GenerateAndInstallCode() { 373 OptimizingCompiler::Status OptimizingCompiler::GenerateAndInstallCode() {
416 ASSERT(last_status() == SUCCEEDED); 374 ASSERT(last_status() == SUCCEEDED);
417 { // Scope for timer. 375 { // Scope for timer.
418 Timer timer(this, &time_taken_to_codegen_); 376 Timer timer(this, &time_taken_to_codegen_);
419 ASSERT(chunk_ != NULL); 377 ASSERT(chunk_ != NULL);
420 ASSERT(graph_ != NULL); 378 ASSERT(graph_ != NULL);
421 Handle<Code> optimized_code = chunk_->Codegen(Code::OPTIMIZED_FUNCTION); 379 Handle<Code> optimized_code = chunk_->Codegen();
422 if (optimized_code.is_null()) { 380 if (optimized_code.is_null()) {
423 info()->set_bailout_reason("code generation failed"); 381 info()->set_bailout_reason("code generation failed");
424 return AbortOptimization(); 382 return AbortOptimization();
425 } 383 }
426 info()->SetCode(optimized_code); 384 info()->SetCode(optimized_code);
427 } 385 }
428 RecordOptimizationStats(); 386 RecordOptimizationStats();
429 return SetLastStatus(SUCCEEDED); 387 return SetLastStatus(SUCCEEDED);
430 } 388 }
431 389
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 } 1070 }
1113 } 1071 }
1114 1072
1115 GDBJIT(AddCode(Handle<String>(shared->DebugName()), 1073 GDBJIT(AddCode(Handle<String>(shared->DebugName()),
1116 Handle<Script>(info->script()), 1074 Handle<Script>(info->script()),
1117 Handle<Code>(info->code()), 1075 Handle<Code>(info->code()),
1118 info)); 1076 info));
1119 } 1077 }
1120 1078
1121 } } // namespace v8::internal 1079 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/deoptimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698