| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 168 } |
| 169 | 169 |
| 170 ParseRestriction parse_restriction() const { | 170 ParseRestriction parse_restriction() const { |
| 171 return ParseRestricitonField::decode(flags_); | 171 return ParseRestricitonField::decode(flags_); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void SetFunction(FunctionLiteral* literal) { | 174 void SetFunction(FunctionLiteral* literal) { |
| 175 ASSERT(function_ == NULL); | 175 ASSERT(function_ == NULL); |
| 176 function_ = literal; | 176 function_ = literal; |
| 177 } | 177 } |
| 178 // When the scope is applied, we may have deferred work to do on the function. | 178 void SetScope(Scope* scope) { |
| 179 void PrepareForCompilation(Scope* scope); | 179 ASSERT(scope_ == NULL); |
| 180 scope_ = scope; |
| 181 } |
| 180 void SetGlobalScope(Scope* global_scope) { | 182 void SetGlobalScope(Scope* global_scope) { |
| 181 ASSERT(global_scope_ == NULL); | 183 ASSERT(global_scope_ == NULL); |
| 182 global_scope_ = global_scope; | 184 global_scope_ = global_scope; |
| 183 } | 185 } |
| 184 void SetCode(Handle<Code> code) { code_ = code; } | 186 void SetCode(Handle<Code> code) { code_ = code; } |
| 185 void SetExtension(v8::Extension* extension) { | 187 void SetExtension(v8::Extension* extension) { |
| 186 ASSERT(!is_lazy()); | 188 ASSERT(!is_lazy()); |
| 187 extension_ = extension; | 189 extension_ = extension; |
| 188 } | 190 } |
| 189 void SetPreParseData(ScriptDataImpl* pre_parse_data) { | 191 void SetPreParseData(ScriptDataImpl* pre_parse_data) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 220 | 222 |
| 221 // Accessors for the different compilation modes. | 223 // Accessors for the different compilation modes. |
| 222 bool IsOptimizing() const { return mode_ == OPTIMIZE; } | 224 bool IsOptimizing() const { return mode_ == OPTIMIZE; } |
| 223 bool IsOptimizable() const { return mode_ == BASE; } | 225 bool IsOptimizable() const { return mode_ == BASE; } |
| 224 bool IsStub() const { return mode_ == STUB; } | 226 bool IsStub() const { return mode_ == STUB; } |
| 225 void SetOptimizing(BailoutId osr_ast_id, Handle<Code> unoptimized) { | 227 void SetOptimizing(BailoutId osr_ast_id, Handle<Code> unoptimized) { |
| 226 ASSERT(!shared_info_.is_null()); | 228 ASSERT(!shared_info_.is_null()); |
| 227 SetMode(OPTIMIZE); | 229 SetMode(OPTIMIZE); |
| 228 osr_ast_id_ = osr_ast_id; | 230 osr_ast_id_ = osr_ast_id; |
| 229 unoptimized_code_ = unoptimized; | 231 unoptimized_code_ = unoptimized; |
| 230 optimization_id_ = isolate()->NextOptimizationId(); | |
| 231 } | 232 } |
| 232 void DisableOptimization(); | 233 void DisableOptimization(); |
| 233 | 234 |
| 234 // Deoptimization support. | 235 // Deoptimization support. |
| 235 bool HasDeoptimizationSupport() const { | 236 bool HasDeoptimizationSupport() const { |
| 236 return SupportsDeoptimization::decode(flags_); | 237 return SupportsDeoptimization::decode(flags_); |
| 237 } | 238 } |
| 238 void EnableDeoptimizationSupport() { | 239 void EnableDeoptimizationSupport() { |
| 239 ASSERT(IsOptimizable()); | 240 ASSERT(IsOptimizable()); |
| 240 flags_ |= SupportsDeoptimization::encode(true); | 241 flags_ |= SupportsDeoptimization::encode(true); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 310 |
| 310 bool HasAbortedDueToDependencyChange() { | 311 bool HasAbortedDueToDependencyChange() { |
| 311 ASSERT(!OptimizingCompilerThread::IsOptimizerThread(isolate())); | 312 ASSERT(!OptimizingCompilerThread::IsOptimizerThread(isolate())); |
| 312 return abort_due_to_dependency_; | 313 return abort_due_to_dependency_; |
| 313 } | 314 } |
| 314 | 315 |
| 315 bool HasSameOsrEntry(Handle<JSFunction> function, BailoutId osr_ast_id) { | 316 bool HasSameOsrEntry(Handle<JSFunction> function, BailoutId osr_ast_id) { |
| 316 return osr_ast_id_ == osr_ast_id && function.is_identical_to(closure_); | 317 return osr_ast_id_ == osr_ast_id && function.is_identical_to(closure_); |
| 317 } | 318 } |
| 318 | 319 |
| 319 int optimization_id() const { return optimization_id_; } | |
| 320 | |
| 321 protected: | 320 protected: |
| 322 CompilationInfo(Handle<Script> script, | 321 CompilationInfo(Handle<Script> script, |
| 323 Zone* zone); | 322 Zone* zone); |
| 324 CompilationInfo(Handle<SharedFunctionInfo> shared_info, | 323 CompilationInfo(Handle<SharedFunctionInfo> shared_info, |
| 325 Zone* zone); | 324 Zone* zone); |
| 326 CompilationInfo(HydrogenCodeStub* stub, | 325 CompilationInfo(HydrogenCodeStub* stub, |
| 327 Isolate* isolate, | 326 Isolate* isolate, |
| 328 Zone* zone); | 327 Zone* zone); |
| 329 | 328 |
| 330 private: | 329 private: |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 // during graph optimization. | 445 // during graph optimization. |
| 447 int opt_count_; | 446 int opt_count_; |
| 448 | 447 |
| 449 // Number of parameters used for compilation of stubs that require arguments. | 448 // Number of parameters used for compilation of stubs that require arguments. |
| 450 int parameter_count_; | 449 int parameter_count_; |
| 451 | 450 |
| 452 bool this_has_uses_; | 451 bool this_has_uses_; |
| 453 | 452 |
| 454 Handle<Foreign> object_wrapper_; | 453 Handle<Foreign> object_wrapper_; |
| 455 | 454 |
| 456 int optimization_id_; | |
| 457 | |
| 458 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); | 455 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); |
| 459 }; | 456 }; |
| 460 | 457 |
| 461 | 458 |
| 462 // Exactly like a CompilationInfo, except also creates and enters a | 459 // Exactly like a CompilationInfo, except also creates and enters a |
| 463 // Zone on construction and deallocates it on exit. | 460 // Zone on construction and deallocates it on exit. |
| 464 class CompilationInfoWithZone: public CompilationInfo { | 461 class CompilationInfoWithZone: public CompilationInfo { |
| 465 public: | 462 public: |
| 466 explicit CompilationInfoWithZone(Handle<Script> script) | 463 explicit CompilationInfoWithZone(Handle<Script> script) |
| 467 : CompilationInfo(script, &zone_), | 464 : CompilationInfo(script, &zone_), |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 unsigned info_zone_start_allocation_size_; | 676 unsigned info_zone_start_allocation_size_; |
| 680 ElapsedTimer timer_; | 677 ElapsedTimer timer_; |
| 681 | 678 |
| 682 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 679 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
| 683 }; | 680 }; |
| 684 | 681 |
| 685 | 682 |
| 686 } } // namespace v8::internal | 683 } } // namespace v8::internal |
| 687 | 684 |
| 688 #endif // V8_COMPILER_H_ | 685 #endif // V8_COMPILER_H_ |
| OLD | NEW |