| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 Scope* global_scope() const { return global_scope_; } | 77 Scope* global_scope() const { return global_scope_; } |
| 78 Handle<Code> code() const { return code_; } | 78 Handle<Code> code() const { return code_; } |
| 79 Handle<JSFunction> closure() const { return closure_; } | 79 Handle<JSFunction> closure() const { return closure_; } |
| 80 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } | 80 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
| 81 Handle<Script> script() const { return script_; } | 81 Handle<Script> script() const { return script_; } |
| 82 HydrogenCodeStub* code_stub() const {return code_stub_; } | 82 HydrogenCodeStub* code_stub() const {return code_stub_; } |
| 83 v8::Extension* extension() const { return extension_; } | 83 v8::Extension* extension() const { return extension_; } |
| 84 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } | 84 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } |
| 85 Handle<Context> context() const { return context_; } | 85 Handle<Context> context() const { return context_; } |
| 86 BailoutId osr_ast_id() const { return osr_ast_id_; } | 86 BailoutId osr_ast_id() const { return osr_ast_id_; } |
| 87 uint32_t osr_pc_offset() const { return osr_pc_offset_; } | 87 Handle<Code> unoptimized_code() const { return unoptimized_code_; } |
| 88 int opt_count() const { return opt_count_; } | 88 int opt_count() const { return opt_count_; } |
| 89 int num_parameters() const; | 89 int num_parameters() const; |
| 90 int num_heap_slots() const; | 90 int num_heap_slots() const; |
| 91 Code::Flags flags() const; | 91 Code::Flags flags() const; |
| 92 | 92 |
| 93 void MarkAsEval() { | 93 void MarkAsEval() { |
| 94 ASSERT(!is_lazy()); | 94 ASSERT(!is_lazy()); |
| 95 flags_ |= IsEval::encode(true); | 95 flags_ |= IsEval::encode(true); |
| 96 } | 96 } |
| 97 void MarkAsGlobal() { | 97 void MarkAsGlobal() { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 ASSERT(!is_lazy()); | 181 ASSERT(!is_lazy()); |
| 182 extension_ = extension; | 182 extension_ = extension; |
| 183 } | 183 } |
| 184 void SetPreParseData(ScriptDataImpl* pre_parse_data) { | 184 void SetPreParseData(ScriptDataImpl* pre_parse_data) { |
| 185 ASSERT(!is_lazy()); | 185 ASSERT(!is_lazy()); |
| 186 pre_parse_data_ = pre_parse_data; | 186 pre_parse_data_ = pre_parse_data; |
| 187 } | 187 } |
| 188 void SetContext(Handle<Context> context) { | 188 void SetContext(Handle<Context> context) { |
| 189 context_ = context; | 189 context_ = context; |
| 190 } | 190 } |
| 191 void MarkCompilingForDebugging(Handle<Code> current_code) { | 191 |
| 192 ASSERT(mode_ != OPTIMIZE); | 192 void MarkCompilingForDebugging() { |
| 193 ASSERT(current_code->kind() == Code::FUNCTION); | |
| 194 flags_ |= IsCompilingForDebugging::encode(true); | 193 flags_ |= IsCompilingForDebugging::encode(true); |
| 195 if (current_code->is_compiled_optimizable()) { | |
| 196 EnableDeoptimizationSupport(); | |
| 197 } else { | |
| 198 mode_ = CompilationInfo::NONOPT; | |
| 199 } | |
| 200 } | 194 } |
| 201 bool IsCompilingForDebugging() { | 195 bool IsCompilingForDebugging() { |
| 202 return IsCompilingForDebugging::decode(flags_); | 196 return IsCompilingForDebugging::decode(flags_); |
| 203 } | 197 } |
| 198 void MarkNonOptimizable() { |
| 199 SetMode(CompilationInfo::NONOPT); |
| 200 } |
| 204 | 201 |
| 205 bool ShouldTrapOnDeopt() const { | 202 bool ShouldTrapOnDeopt() const { |
| 206 return (FLAG_trap_on_deopt && IsOptimizing()) || | 203 return (FLAG_trap_on_deopt && IsOptimizing()) || |
| 207 (FLAG_trap_on_stub_deopt && IsStub()); | 204 (FLAG_trap_on_stub_deopt && IsStub()); |
| 208 } | 205 } |
| 209 | 206 |
| 210 bool has_global_object() const { | 207 bool has_global_object() const { |
| 211 return !closure().is_null() && | 208 return !closure().is_null() && |
| 212 (closure()->context()->global_object() != NULL); | 209 (closure()->context()->global_object() != NULL); |
| 213 } | 210 } |
| 214 | 211 |
| 215 GlobalObject* global_object() const { | 212 GlobalObject* global_object() const { |
| 216 return has_global_object() ? closure()->context()->global_object() : NULL; | 213 return has_global_object() ? closure()->context()->global_object() : NULL; |
| 217 } | 214 } |
| 218 | 215 |
| 219 // Accessors for the different compilation modes. | 216 // Accessors for the different compilation modes. |
| 220 bool IsOptimizing() const { return mode_ == OPTIMIZE; } | 217 bool IsOptimizing() const { return mode_ == OPTIMIZE; } |
| 221 bool IsOptimizable() const { return mode_ == BASE; } | 218 bool IsOptimizable() const { return mode_ == BASE; } |
| 222 bool IsStub() const { return mode_ == STUB; } | 219 bool IsStub() const { return mode_ == STUB; } |
| 223 void SetOptimizing(BailoutId osr_ast_id) { | 220 void SetOptimizing(BailoutId osr_ast_id, Handle<Code> unoptimized) { |
| 221 ASSERT(!shared_info_.is_null()); |
| 224 SetMode(OPTIMIZE); | 222 SetMode(OPTIMIZE); |
| 225 osr_ast_id_ = osr_ast_id; | 223 osr_ast_id_ = osr_ast_id; |
| 224 unoptimized_code_ = unoptimized; |
| 226 } | 225 } |
| 227 void DisableOptimization(); | 226 void DisableOptimization(); |
| 228 | 227 |
| 229 // Deoptimization support. | 228 // Deoptimization support. |
| 230 bool HasDeoptimizationSupport() const { | 229 bool HasDeoptimizationSupport() const { |
| 231 return SupportsDeoptimization::decode(flags_); | 230 return SupportsDeoptimization::decode(flags_); |
| 232 } | 231 } |
| 233 void EnableDeoptimizationSupport() { | 232 void EnableDeoptimizationSupport() { |
| 234 ASSERT(IsOptimizable()); | 233 ASSERT(IsOptimizable()); |
| 235 flags_ |= SupportsDeoptimization::encode(true); | 234 flags_ |= SupportsDeoptimization::encode(true); |
| 236 } | 235 } |
| 237 | 236 |
| 238 // Determines whether or not to insert a self-optimization header. | 237 // Determines whether or not to insert a self-optimization header. |
| 239 bool ShouldSelfOptimize(); | 238 bool ShouldSelfOptimize(); |
| 240 | 239 |
| 241 // Reset code to the unoptimized version when optimization is aborted. | |
| 242 void AbortOptimization() { | |
| 243 SetCode(handle(shared_info()->code())); | |
| 244 } | |
| 245 | |
| 246 void set_deferred_handles(DeferredHandles* deferred_handles) { | 240 void set_deferred_handles(DeferredHandles* deferred_handles) { |
| 247 ASSERT(deferred_handles_ == NULL); | 241 ASSERT(deferred_handles_ == NULL); |
| 248 deferred_handles_ = deferred_handles; | 242 deferred_handles_ = deferred_handles; |
| 249 } | 243 } |
| 250 | 244 |
| 251 ZoneList<Handle<HeapObject> >* dependencies( | 245 ZoneList<Handle<HeapObject> >* dependencies( |
| 252 DependentCode::DependencyGroup group) { | 246 DependentCode::DependencyGroup group) { |
| 253 if (dependencies_[group] == NULL) { | 247 if (dependencies_[group] == NULL) { |
| 254 dependencies_[group] = new(zone_) ZoneList<Handle<HeapObject> >(2, zone_); | 248 dependencies_[group] = new(zone_) ZoneList<Handle<HeapObject> >(2, zone_); |
| 255 } | 249 } |
| 256 return dependencies_[group]; | 250 return dependencies_[group]; |
| 257 } | 251 } |
| 258 | 252 |
| 259 void CommitDependencies(Handle<Code> code); | 253 void CommitDependencies(Handle<Code> code); |
| 260 | 254 |
| 261 void RollbackDependencies(); | 255 void RollbackDependencies(); |
| 262 | 256 |
| 263 void SaveHandles() { | 257 void SaveHandles() { |
| 264 SaveHandle(&closure_); | 258 SaveHandle(&closure_); |
| 265 SaveHandle(&shared_info_); | 259 SaveHandle(&shared_info_); |
| 266 SaveHandle(&context_); | 260 SaveHandle(&context_); |
| 267 SaveHandle(&script_); | 261 SaveHandle(&script_); |
| 262 SaveHandle(&unoptimized_code_); |
| 268 } | 263 } |
| 269 | 264 |
| 270 BailoutReason bailout_reason() const { return bailout_reason_; } | 265 BailoutReason bailout_reason() const { return bailout_reason_; } |
| 271 void set_bailout_reason(BailoutReason reason) { bailout_reason_ = reason; } | 266 void set_bailout_reason(BailoutReason reason) { bailout_reason_ = reason; } |
| 272 | 267 |
| 273 int prologue_offset() const { | 268 int prologue_offset() const { |
| 274 ASSERT_NE(Code::kPrologueOffsetNotSet, prologue_offset_); | 269 ASSERT_NE(Code::kPrologueOffsetNotSet, prologue_offset_); |
| 275 return prologue_offset_; | 270 return prologue_offset_; |
| 276 } | 271 } |
| 277 | 272 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 304 void AbortDueToDependencyChange() { | 299 void AbortDueToDependencyChange() { |
| 305 ASSERT(!OptimizingCompilerThread::IsOptimizerThread(isolate())); | 300 ASSERT(!OptimizingCompilerThread::IsOptimizerThread(isolate())); |
| 306 abort_due_to_dependency_ = true; | 301 abort_due_to_dependency_ = true; |
| 307 } | 302 } |
| 308 | 303 |
| 309 bool HasAbortedDueToDependencyChange() { | 304 bool HasAbortedDueToDependencyChange() { |
| 310 ASSERT(!OptimizingCompilerThread::IsOptimizerThread(isolate())); | 305 ASSERT(!OptimizingCompilerThread::IsOptimizerThread(isolate())); |
| 311 return abort_due_to_dependency_; | 306 return abort_due_to_dependency_; |
| 312 } | 307 } |
| 313 | 308 |
| 314 void set_osr_pc_offset(uint32_t pc_offset) { | 309 bool HasSameOsrEntry(Handle<JSFunction> function, BailoutId osr_ast_id) { |
| 315 osr_pc_offset_ = pc_offset; | 310 return osr_ast_id_ == osr_ast_id && function.is_identical_to(closure_); |
| 316 } | |
| 317 | |
| 318 bool HasSameOsrEntry(Handle<JSFunction> function, uint32_t pc_offset) { | |
| 319 return osr_pc_offset_ == pc_offset && function.is_identical_to(closure_); | |
| 320 } | 311 } |
| 321 | 312 |
| 322 protected: | 313 protected: |
| 323 CompilationInfo(Handle<Script> script, | 314 CompilationInfo(Handle<Script> script, |
| 324 Zone* zone); | 315 Zone* zone); |
| 325 CompilationInfo(Handle<SharedFunctionInfo> shared_info, | 316 CompilationInfo(Handle<SharedFunctionInfo> shared_info, |
| 326 Zone* zone); | 317 Zone* zone); |
| 327 CompilationInfo(HydrogenCodeStub* stub, | 318 CompilationInfo(HydrogenCodeStub* stub, |
| 328 Isolate* isolate, | 319 Isolate* isolate, |
| 329 Zone* zone); | 320 Zone* zone); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 v8::Extension* extension_; | 397 v8::Extension* extension_; |
| 407 ScriptDataImpl* pre_parse_data_; | 398 ScriptDataImpl* pre_parse_data_; |
| 408 | 399 |
| 409 // The context of the caller for eval code, and the global context for a | 400 // The context of the caller for eval code, and the global context for a |
| 410 // global script. Will be a null handle otherwise. | 401 // global script. Will be a null handle otherwise. |
| 411 Handle<Context> context_; | 402 Handle<Context> context_; |
| 412 | 403 |
| 413 // Compilation mode flag and whether deoptimization is allowed. | 404 // Compilation mode flag and whether deoptimization is allowed. |
| 414 Mode mode_; | 405 Mode mode_; |
| 415 BailoutId osr_ast_id_; | 406 BailoutId osr_ast_id_; |
| 416 // The pc_offset corresponding to osr_ast_id_ in unoptimized code. | 407 // The unoptimized code we patched for OSR may not be the shared code |
| 417 // We can look this up in the back edge table, but cache it for quick access. | 408 // afterwards, since we may need to compile it again to include deoptimization |
| 418 uint32_t osr_pc_offset_; | 409 // data. Keep track which code we patched. |
| 410 Handle<Code> unoptimized_code_; |
| 419 | 411 |
| 420 // Flag whether compilation needs to be aborted due to dependency change. | 412 // Flag whether compilation needs to be aborted due to dependency change. |
| 421 bool abort_due_to_dependency_; | 413 bool abort_due_to_dependency_; |
| 422 | 414 |
| 423 // The zone from which the compilation pipeline working on this | 415 // The zone from which the compilation pipeline working on this |
| 424 // CompilationInfo allocates. | 416 // CompilationInfo allocates. |
| 425 Zone* zone_; | 417 Zone* zone_; |
| 426 | 418 |
| 427 DeferredHandles* deferred_handles_; | 419 DeferredHandles* deferred_handles_; |
| 428 | 420 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 class HGraph; | 496 class HGraph; |
| 505 class HOptimizedGraphBuilder; | 497 class HOptimizedGraphBuilder; |
| 506 class LChunk; | 498 class LChunk; |
| 507 | 499 |
| 508 // A helper class that calls the three compilation phases in | 500 // A helper class that calls the three compilation phases in |
| 509 // Crankshaft and keeps track of its state. The three phases | 501 // Crankshaft and keeps track of its state. The three phases |
| 510 // CreateGraph, OptimizeGraph and GenerateAndInstallCode can either | 502 // CreateGraph, OptimizeGraph and GenerateAndInstallCode can either |
| 511 // fail, bail-out to the full code generator or succeed. Apart from | 503 // fail, bail-out to the full code generator or succeed. Apart from |
| 512 // their return value, the status of the phase last run can be checked | 504 // their return value, the status of the phase last run can be checked |
| 513 // using last_status(). | 505 // using last_status(). |
| 514 class RecompileJob: public ZoneObject { | 506 class OptimizedCompileJob: public ZoneObject { |
| 515 public: | 507 public: |
| 516 explicit RecompileJob(CompilationInfo* info) | 508 explicit OptimizedCompileJob(CompilationInfo* info) |
| 517 : info_(info), | 509 : info_(info), |
| 518 graph_builder_(NULL), | 510 graph_builder_(NULL), |
| 519 graph_(NULL), | 511 graph_(NULL), |
| 520 chunk_(NULL), | 512 chunk_(NULL), |
| 521 last_status_(FAILED), | 513 last_status_(FAILED), |
| 522 awaiting_install_(false) { } | 514 awaiting_install_(false) { } |
| 523 | 515 |
| 524 enum Status { | 516 enum Status { |
| 525 FAILED, BAILED_OUT, SUCCEEDED | 517 FAILED, BAILED_OUT, SUCCEEDED |
| 526 }; | 518 }; |
| 527 | 519 |
| 528 MUST_USE_RESULT Status CreateGraph(); | 520 MUST_USE_RESULT Status CreateGraph(); |
| 529 MUST_USE_RESULT Status OptimizeGraph(); | 521 MUST_USE_RESULT Status OptimizeGraph(); |
| 530 MUST_USE_RESULT Status GenerateAndInstallCode(); | 522 MUST_USE_RESULT Status GenerateCode(); |
| 531 | 523 |
| 532 Status last_status() const { return last_status_; } | 524 Status last_status() const { return last_status_; } |
| 533 CompilationInfo* info() const { return info_; } | 525 CompilationInfo* info() const { return info_; } |
| 534 Isolate* isolate() const { return info()->isolate(); } | 526 Isolate* isolate() const { return info()->isolate(); } |
| 535 | 527 |
| 536 MUST_USE_RESULT Status AbortOptimization() { | 528 MUST_USE_RESULT Status AbortOptimization( |
| 537 info_->AbortOptimization(); | 529 BailoutReason reason = kNoReason) { |
| 530 if (reason != kNoReason) info_->set_bailout_reason(reason); |
| 531 return SetLastStatus(BAILED_OUT); |
| 532 } |
| 533 |
| 534 MUST_USE_RESULT Status AbortAndDisableOptimization( |
| 535 BailoutReason reason = kNoReason) { |
| 536 if (reason != kNoReason) info_->set_bailout_reason(reason); |
| 538 info_->shared_info()->DisableOptimization(info_->bailout_reason()); | 537 info_->shared_info()->DisableOptimization(info_->bailout_reason()); |
| 539 return SetLastStatus(BAILED_OUT); | 538 return SetLastStatus(BAILED_OUT); |
| 540 } | 539 } |
| 541 | 540 |
| 542 void WaitForInstall() { | 541 void WaitForInstall() { |
| 543 ASSERT(info_->is_osr()); | 542 ASSERT(info_->is_osr()); |
| 544 awaiting_install_ = true; | 543 awaiting_install_ = true; |
| 545 } | 544 } |
| 546 | 545 |
| 547 bool IsWaitingForInstall() { return awaiting_install_; } | 546 bool IsWaitingForInstall() { return awaiting_install_; } |
| 548 | 547 |
| 549 private: | 548 private: |
| 550 CompilationInfo* info_; | 549 CompilationInfo* info_; |
| 551 HOptimizedGraphBuilder* graph_builder_; | 550 HOptimizedGraphBuilder* graph_builder_; |
| 552 HGraph* graph_; | 551 HGraph* graph_; |
| 553 LChunk* chunk_; | 552 LChunk* chunk_; |
| 554 TimeDelta time_taken_to_create_graph_; | 553 TimeDelta time_taken_to_create_graph_; |
| 555 TimeDelta time_taken_to_optimize_; | 554 TimeDelta time_taken_to_optimize_; |
| 556 TimeDelta time_taken_to_codegen_; | 555 TimeDelta time_taken_to_codegen_; |
| 557 Status last_status_; | 556 Status last_status_; |
| 558 bool awaiting_install_; | 557 bool awaiting_install_; |
| 559 | 558 |
| 560 MUST_USE_RESULT Status SetLastStatus(Status status) { | 559 MUST_USE_RESULT Status SetLastStatus(Status status) { |
| 561 last_status_ = status; | 560 last_status_ = status; |
| 562 return last_status_; | 561 return last_status_; |
| 563 } | 562 } |
| 564 void RecordOptimizationStats(); | 563 void RecordOptimizationStats(); |
| 565 | 564 |
| 566 struct Timer { | 565 struct Timer { |
| 567 Timer(RecompileJob* job, TimeDelta* location) | 566 Timer(OptimizedCompileJob* job, TimeDelta* location) |
| 568 : job_(job), location_(location) { | 567 : job_(job), location_(location) { |
| 569 ASSERT(location_ != NULL); | 568 ASSERT(location_ != NULL); |
| 570 timer_.Start(); | 569 timer_.Start(); |
| 571 } | 570 } |
| 572 | 571 |
| 573 ~Timer() { | 572 ~Timer() { |
| 574 *location_ += timer_.Elapsed(); | 573 *location_ += timer_.Elapsed(); |
| 575 } | 574 } |
| 576 | 575 |
| 577 RecompileJob* job_; | 576 OptimizedCompileJob* job_; |
| 578 ElapsedTimer timer_; | 577 ElapsedTimer timer_; |
| 579 TimeDelta* location_; | 578 TimeDelta* location_; |
| 580 }; | 579 }; |
| 581 }; | 580 }; |
| 582 | 581 |
| 583 | 582 |
| 584 // The V8 compiler | 583 // The V8 compiler |
| 585 // | 584 // |
| 586 // General strategy: Source code is translated into an anonymous function w/o | 585 // General strategy: Source code is translated into an anonymous function w/o |
| 587 // parameters which then can be executed. If the source code contains other | 586 // parameters which then can be executed. If the source code contains other |
| 588 // functions, they will be compiled and allocated as part of the compilation | 587 // functions, they will be compiled and allocated as part of the compilation |
| 589 // of the source code. | 588 // of the source code. |
| 590 | 589 |
| 591 // Please note this interface returns shared function infos. This means you | 590 // Please note this interface returns shared function infos. This means you |
| 592 // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a | 591 // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a |
| 593 // real function with a context. | 592 // real function with a context. |
| 594 | 593 |
| 595 class Compiler : public AllStatic { | 594 class Compiler : public AllStatic { |
| 596 public: | 595 public: |
| 597 // Call count before primitive functions trigger their own optimization. | 596 static Handle<Code> GetUnoptimizedCode(Handle<JSFunction> function); |
| 598 static const int kCallsUntilPrimitiveOpt = 200; | 597 static Handle<Code> GetUnoptimizedCode(Handle<SharedFunctionInfo> shared); |
| 598 static bool EnsureCompiled(Handle<JSFunction> function, |
| 599 ClearExceptionFlag flag); |
| 600 static Handle<Code> GetCodeForDebugging(Handle<JSFunction> function); |
| 599 | 601 |
| 600 // All routines return a SharedFunctionInfo. | 602 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 601 // If an error occurs an exception is raised and the return handle | 603 static void CompileForLiveEdit(Handle<Script> script); |
| 602 // contains NULL. | 604 #endif |
| 603 | 605 |
| 604 // Compile a String source within a context. | 606 // Compile a String source within a context for eval. |
| 605 static Handle<SharedFunctionInfo> Compile(Handle<String> source, | 607 static Handle<JSFunction> GetFunctionFromEval(Handle<String> source, |
| 606 Handle<Object> script_name, | |
| 607 int line_offset, | |
| 608 int column_offset, | |
| 609 bool is_shared_cross_origin, | |
| 610 Handle<Context> context, | |
| 611 v8::Extension* extension, | |
| 612 ScriptDataImpl* pre_data, | |
| 613 Handle<Object> script_data, | |
| 614 NativesFlag is_natives_code); | |
| 615 | |
| 616 // Compile a String source within a context for Eval. | |
| 617 static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, | |
| 618 Handle<Context> context, | 608 Handle<Context> context, |
| 619 bool is_global, | |
| 620 LanguageMode language_mode, | 609 LanguageMode language_mode, |
| 621 ParseRestriction restriction, | 610 ParseRestriction restriction, |
| 622 int scope_position); | 611 int scope_position); |
| 623 | 612 |
| 624 // Compile from function info (used for lazy compilation). Returns true on | 613 // Compile a String source within a context. |
| 625 // success and false if the compilation resulted in a stack overflow. | 614 static Handle<SharedFunctionInfo> CompileScript(Handle<String> source, |
| 626 static bool CompileLazy(CompilationInfo* info); | 615 Handle<Object> script_name, |
| 616 int line_offset, |
| 617 int column_offset, |
| 618 bool is_shared_cross_origin, |
| 619 Handle<Context> context, |
| 620 v8::Extension* extension, |
| 621 ScriptDataImpl* pre_data, |
| 622 Handle<Object> script_data, |
| 623 NativesFlag is_natives_code); |
| 627 | 624 |
| 628 static bool RecompileConcurrent(Handle<JSFunction> function, | 625 // Create a shared function info object (the code may be lazily compiled). |
| 629 uint32_t osr_pc_offset = 0); | |
| 630 | |
| 631 // Compile a shared function info object (the function is possibly lazily | |
| 632 // compiled). | |
| 633 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, | 626 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, |
| 634 Handle<Script> script); | 627 Handle<Script> script); |
| 635 | 628 |
| 636 // Set the function info for a newly compiled function. | 629 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; |
| 637 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, | |
| 638 FunctionLiteral* lit, | |
| 639 bool is_toplevel, | |
| 640 Handle<Script> script); | |
| 641 | 630 |
| 642 static Handle<Code> InstallOptimizedCode(RecompileJob* job); | 631 // Generate and return optimized code or start a concurrent optimization job. |
| 632 // In the latter case, return the InOptimizationQueue builtin. On failure, |
| 633 // return the empty handle. |
| 634 static Handle<Code> GetOptimizedCode( |
| 635 Handle<JSFunction> function, |
| 636 Handle<Code> current_code, |
| 637 ConcurrencyMode mode, |
| 638 BailoutId osr_ast_id = BailoutId::None()); |
| 643 | 639 |
| 644 #ifdef ENABLE_DEBUGGER_SUPPORT | 640 // Generate and return code from previously queued optimization job. |
| 645 static bool MakeCodeForLiveEdit(CompilationInfo* info); | 641 // On failure, return the empty handle. |
| 646 #endif | 642 static Handle<Code> GetConcurrentlyOptimizedCode(OptimizedCompileJob* job); |
| 647 | 643 |
| 648 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 644 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
| 649 CompilationInfo* info, | 645 CompilationInfo* info, |
| 650 Handle<SharedFunctionInfo> shared); | 646 Handle<SharedFunctionInfo> shared); |
| 651 }; | 647 }; |
| 652 | 648 |
| 653 | 649 |
| 654 class CompilationPhase BASE_EMBEDDED { | 650 class CompilationPhase BASE_EMBEDDED { |
| 655 public: | 651 public: |
| 656 CompilationPhase(const char* name, CompilationInfo* info); | 652 CompilationPhase(const char* name, CompilationInfo* info); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 671 unsigned info_zone_start_allocation_size_; | 667 unsigned info_zone_start_allocation_size_; |
| 672 ElapsedTimer timer_; | 668 ElapsedTimer timer_; |
| 673 | 669 |
| 674 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 670 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
| 675 }; | 671 }; |
| 676 | 672 |
| 677 | 673 |
| 678 } } // namespace v8::internal | 674 } } // namespace v8::internal |
| 679 | 675 |
| 680 #endif // V8_COMPILER_H_ | 676 #endif // V8_COMPILER_H_ |
| OLD | NEW |