OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_H_ | 5 #ifndef V8_COMPILER_H_ |
6 #define V8_COMPILER_H_ | 6 #define V8_COMPILER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 Isolate* isolate() const { | 185 Isolate* isolate() const { |
186 return isolate_; | 186 return isolate_; |
187 } | 187 } |
188 Zone* zone() { return zone_; } | 188 Zone* zone() { return zone_; } |
189 bool is_osr() const { return !osr_ast_id_.IsNone(); } | 189 bool is_osr() const { return !osr_ast_id_.IsNone(); } |
190 Handle<JSFunction> closure() const { return closure_; } | 190 Handle<JSFunction> closure() const { return closure_; } |
191 Handle<Code> code() const { return code_; } | 191 Handle<Code> code() const { return code_; } |
192 Code::Flags code_flags() const { return code_flags_; } | 192 Code::Flags code_flags() const { return code_flags_; } |
193 BailoutId osr_ast_id() const { return osr_ast_id_; } | 193 BailoutId osr_ast_id() const { return osr_ast_id_; } |
| 194 JavaScriptFrame* osr_frame() const { return osr_frame_; } |
194 int num_parameters() const; | 195 int num_parameters() const; |
195 int num_parameters_including_this() const; | 196 int num_parameters_including_this() const; |
196 bool is_this_defined() const; | 197 bool is_this_defined() const; |
197 | 198 |
198 void set_parameter_count(int parameter_count) { | 199 void set_parameter_count(int parameter_count) { |
199 DCHECK(IsStub()); | 200 DCHECK(IsStub()); |
200 parameter_count_ = parameter_count; | 201 parameter_count_ = parameter_count; |
201 } | 202 } |
202 | 203 |
203 bool has_bytecode_array() const { return !bytecode_array_.is_null(); } | 204 bool has_bytecode_array() const { return !bytecode_array_.is_null(); } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 // Accessors for the different compilation modes. | 334 // Accessors for the different compilation modes. |
334 bool IsOptimizing() const { return mode_ == OPTIMIZE; } | 335 bool IsOptimizing() const { return mode_ == OPTIMIZE; } |
335 bool IsStub() const { return mode_ == STUB; } | 336 bool IsStub() const { return mode_ == STUB; } |
336 void SetOptimizing() { | 337 void SetOptimizing() { |
337 DCHECK(has_shared_info()); | 338 DCHECK(has_shared_info()); |
338 SetMode(OPTIMIZE); | 339 SetMode(OPTIMIZE); |
339 optimization_id_ = isolate()->NextOptimizationId(); | 340 optimization_id_ = isolate()->NextOptimizationId(); |
340 code_flags_ = | 341 code_flags_ = |
341 Code::KindField::update(code_flags_, Code::OPTIMIZED_FUNCTION); | 342 Code::KindField::update(code_flags_, Code::OPTIMIZED_FUNCTION); |
342 } | 343 } |
343 void SetOptimizingForOsr(BailoutId osr_ast_id) { | 344 void SetOptimizingForOsr(BailoutId osr_ast_id, JavaScriptFrame* osr_frame) { |
344 SetOptimizing(); | 345 SetOptimizing(); |
345 osr_ast_id_ = osr_ast_id; | 346 osr_ast_id_ = osr_ast_id; |
| 347 osr_frame_ = osr_frame; |
346 } | 348 } |
347 | 349 |
348 // Deoptimization support. | 350 // Deoptimization support. |
349 bool HasDeoptimizationSupport() const { | 351 bool HasDeoptimizationSupport() const { |
350 return GetFlag(kDeoptimizationSupport); | 352 return GetFlag(kDeoptimizationSupport); |
351 } | 353 } |
352 void EnableDeoptimizationSupport() { | 354 void EnableDeoptimizationSupport() { |
353 DCHECK_EQ(BASE, mode_); | 355 DCHECK_EQ(BASE, mode_); |
354 SetFlag(kDeoptimizationSupport); | 356 SetFlag(kDeoptimizationSupport); |
355 } | 357 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 DCHECK_EQ(Code::kPrologueOffsetNotSet, prologue_offset_); | 394 DCHECK_EQ(Code::kPrologueOffsetNotSet, prologue_offset_); |
393 prologue_offset_ = prologue_offset; | 395 prologue_offset_ = prologue_offset; |
394 } | 396 } |
395 | 397 |
396 std::vector<InlinedFunctionInfo>& inlined_function_infos() { | 398 std::vector<InlinedFunctionInfo>& inlined_function_infos() { |
397 return inlined_function_infos_; | 399 return inlined_function_infos_; |
398 } | 400 } |
399 | 401 |
400 CompilationDependencies* dependencies() { return &dependencies_; } | 402 CompilationDependencies* dependencies() { return &dependencies_; } |
401 | 403 |
402 bool HasSameOsrEntry(Handle<JSFunction> function, BailoutId osr_ast_id) { | |
403 return osr_ast_id_ == osr_ast_id && function.is_identical_to(closure()); | |
404 } | |
405 | |
406 int optimization_id() const { return optimization_id_; } | 404 int optimization_id() const { return optimization_id_; } |
407 | 405 |
408 int osr_expr_stack_height() { return osr_expr_stack_height_; } | 406 int osr_expr_stack_height() { return osr_expr_stack_height_; } |
409 void set_osr_expr_stack_height(int height) { | 407 void set_osr_expr_stack_height(int height) { |
410 DCHECK(height >= 0); | 408 DCHECK(height >= 0); |
411 osr_expr_stack_height_ = height; | 409 osr_expr_stack_height_ = height; |
412 } | 410 } |
413 JavaScriptFrame* osr_frame() const { return osr_frame_; } | |
414 void set_osr_frame(JavaScriptFrame* osr_frame) { osr_frame_ = osr_frame; } | |
415 | 411 |
416 #if DEBUG | 412 #if DEBUG |
417 void PrintAstForTesting(); | 413 void PrintAstForTesting(); |
418 #endif | 414 #endif |
419 | 415 |
420 bool has_simple_parameters(); | 416 bool has_simple_parameters(); |
421 | 417 |
422 struct InlinedFunctionHolder { | 418 struct InlinedFunctionHolder { |
423 Handle<SharedFunctionInfo> shared_info; | 419 Handle<SharedFunctionInfo> shared_info; |
424 | 420 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 MUST_USE_RESULT Status SetLastStatus(Status status) { | 607 MUST_USE_RESULT Status SetLastStatus(Status status) { |
612 last_status_ = status; | 608 last_status_ = status; |
613 return last_status_; | 609 return last_status_; |
614 } | 610 } |
615 }; | 611 }; |
616 | 612 |
617 } // namespace internal | 613 } // namespace internal |
618 } // namespace v8 | 614 } // namespace v8 |
619 | 615 |
620 #endif // V8_COMPILER_H_ | 616 #endif // V8_COMPILER_H_ |
OLD | NEW |