| OLD | NEW |
| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 | 208 |
| 209 Code::Flags CompilationInfo::flags() const { | 209 Code::Flags CompilationInfo::flags() const { |
| 210 if (IsStub()) { | 210 if (IsStub()) { |
| 211 return Code::ComputeFlags(code_stub()->GetCodeKind(), | 211 return Code::ComputeFlags(code_stub()->GetCodeKind(), |
| 212 code_stub()->GetICState(), | 212 code_stub()->GetICState(), |
| 213 code_stub()->GetExtraICState(), | 213 code_stub()->GetExtraICState(), |
| 214 code_stub()->GetStubType(), | 214 code_stub()->GetStubType(), |
| 215 code_stub()->GetStubFlags()); | 215 code_stub()->GetHandlerKind()); |
| 216 } else { | 216 } else { |
| 217 return Code::ComputeFlags(Code::OPTIMIZED_FUNCTION); | 217 return Code::ComputeFlags(Code::OPTIMIZED_FUNCTION); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 | 221 |
| 222 // Disable optimization for the rest of the compilation pipeline. | 222 // Disable optimization for the rest of the compilation pipeline. |
| 223 void CompilationInfo::DisableOptimization() { | 223 void CompilationInfo::DisableOptimization() { |
| 224 bool is_optimizable_closure = | 224 bool is_optimizable_closure = |
| 225 FLAG_optimize_closures && | 225 FLAG_optimize_closures && |
| (...skipping 10 matching lines...) Expand all Loading... |
| 236 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. | 236 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. |
| 237 bool CompilationInfo::ShouldSelfOptimize() { | 237 bool CompilationInfo::ShouldSelfOptimize() { |
| 238 return FLAG_crankshaft && | 238 return FLAG_crankshaft && |
| 239 !function()->flags()->Contains(kDontSelfOptimize) && | 239 !function()->flags()->Contains(kDontSelfOptimize) && |
| 240 !function()->dont_optimize() && | 240 !function()->dont_optimize() && |
| 241 function()->scope()->AllowsLazyCompilation() && | 241 function()->scope()->AllowsLazyCompilation() && |
| 242 (shared_info().is_null() || !shared_info()->optimization_disabled()); | 242 (shared_info().is_null() || !shared_info()->optimization_disabled()); |
| 243 } | 243 } |
| 244 | 244 |
| 245 | 245 |
| 246 void CompilationInfo::PrepareForCompilation(Scope* scope) { |
| 247 ASSERT(scope_ == NULL); |
| 248 scope_ = scope; |
| 249 function()->ProcessFeedbackSlots(isolate_); |
| 250 } |
| 251 |
| 252 |
| 246 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { | 253 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { |
| 247 public: | 254 public: |
| 248 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) | 255 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) |
| 249 : HOptimizedGraphBuilder(info) { | 256 : HOptimizedGraphBuilder(info) { |
| 250 } | 257 } |
| 251 | 258 |
| 252 #define DEF_VISIT(type) \ | 259 #define DEF_VISIT(type) \ |
| 253 virtual void Visit##type(type* node) V8_OVERRIDE { \ | 260 virtual void Visit##type(type* node) V8_OVERRIDE { \ |
| 254 if (node->position() != RelocInfo::kNoPosition) { \ | 261 if (node->position() != RelocInfo::kNoPosition) { \ |
| 255 SetSourcePosition(node->position()); \ | 262 SetSourcePosition(node->position()); \ |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 bool should_recompile = !info()->shared_info()->has_deoptimization_support(); | 372 bool should_recompile = !info()->shared_info()->has_deoptimization_support(); |
| 366 if (should_recompile || FLAG_hydrogen_stats) { | 373 if (should_recompile || FLAG_hydrogen_stats) { |
| 367 ElapsedTimer timer; | 374 ElapsedTimer timer; |
| 368 if (FLAG_hydrogen_stats) { | 375 if (FLAG_hydrogen_stats) { |
| 369 timer.Start(); | 376 timer.Start(); |
| 370 } | 377 } |
| 371 CompilationInfoWithZone unoptimized(info()->shared_info()); | 378 CompilationInfoWithZone unoptimized(info()->shared_info()); |
| 372 // Note that we use the same AST that we will use for generating the | 379 // Note that we use the same AST that we will use for generating the |
| 373 // optimized code. | 380 // optimized code. |
| 374 unoptimized.SetFunction(info()->function()); | 381 unoptimized.SetFunction(info()->function()); |
| 375 unoptimized.SetScope(info()->scope()); | 382 unoptimized.PrepareForCompilation(info()->scope()); |
| 376 unoptimized.SetContext(info()->context()); | 383 unoptimized.SetContext(info()->context()); |
| 377 if (should_recompile) unoptimized.EnableDeoptimizationSupport(); | 384 if (should_recompile) unoptimized.EnableDeoptimizationSupport(); |
| 378 bool succeeded = FullCodeGenerator::MakeCode(&unoptimized); | 385 bool succeeded = FullCodeGenerator::MakeCode(&unoptimized); |
| 379 if (should_recompile) { | 386 if (should_recompile) { |
| 380 if (!succeeded) return SetLastStatus(FAILED); | 387 if (!succeeded) return SetLastStatus(FAILED); |
| 381 Handle<SharedFunctionInfo> shared = info()->shared_info(); | 388 Handle<SharedFunctionInfo> shared = info()->shared_info(); |
| 382 shared->EnableDeoptimizationSupport(*unoptimized.code()); | 389 shared->EnableDeoptimizationSupport(*unoptimized.code()); |
| 383 // The existing unoptimized code was replaced with the new one. | 390 // The existing unoptimized code was replaced with the new one. |
| 384 Compiler::RecordFunctionCompilation( | 391 Compiler::RecordFunctionCompilation( |
| 385 Logger::LAZY_COMPILE_TAG, &unoptimized, shared); | 392 Logger::LAZY_COMPILE_TAG, &unoptimized, shared); |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 if (result.is_null()) isolate->ReportPendingMessages(); | 991 if (result.is_null()) isolate->ReportPendingMessages(); |
| 985 return result; | 992 return result; |
| 986 } | 993 } |
| 987 | 994 |
| 988 | 995 |
| 989 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, | 996 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, |
| 990 Handle<Script> script) { | 997 Handle<Script> script) { |
| 991 // Precondition: code has been parsed and scopes have been analyzed. | 998 // Precondition: code has been parsed and scopes have been analyzed. |
| 992 CompilationInfoWithZone info(script); | 999 CompilationInfoWithZone info(script); |
| 993 info.SetFunction(literal); | 1000 info.SetFunction(literal); |
| 994 info.SetScope(literal->scope()); | 1001 info.PrepareForCompilation(literal->scope()); |
| 995 info.SetLanguageMode(literal->scope()->language_mode()); | 1002 info.SetLanguageMode(literal->scope()->language_mode()); |
| 996 | 1003 |
| 997 Isolate* isolate = info.isolate(); | 1004 Isolate* isolate = info.isolate(); |
| 998 Factory* factory = isolate->factory(); | 1005 Factory* factory = isolate->factory(); |
| 999 LiveEditFunctionTracker live_edit_tracker(isolate, literal); | 1006 LiveEditFunctionTracker live_edit_tracker(isolate, literal); |
| 1000 // Determine if the function can be lazily compiled. This is necessary to | 1007 // Determine if the function can be lazily compiled. This is necessary to |
| 1001 // allow some of our builtin JS files to be lazily compiled. These | 1008 // allow some of our builtin JS files to be lazily compiled. These |
| 1002 // builtins cannot be handled lazily by the parser, since we have to know | 1009 // builtins cannot be handled lazily by the parser, since we have to know |
| 1003 // if a function uses the special natives syntax, which is something the | 1010 // if a function uses the special natives syntax, which is something the |
| 1004 // parser records. | 1011 // parser records. |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 AllowHandleDereference allow_deref; | 1307 AllowHandleDereference allow_deref; |
| 1301 bool tracing_on = info()->IsStub() | 1308 bool tracing_on = info()->IsStub() |
| 1302 ? FLAG_trace_hydrogen_stubs | 1309 ? FLAG_trace_hydrogen_stubs |
| 1303 : (FLAG_trace_hydrogen && | 1310 : (FLAG_trace_hydrogen && |
| 1304 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1311 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1305 return (tracing_on && | 1312 return (tracing_on && |
| 1306 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1313 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1307 } | 1314 } |
| 1308 | 1315 |
| 1309 } } // namespace v8::internal | 1316 } } // namespace v8::internal |
| OLD | NEW |