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

Side by Side Diff: src/full-codegen/full-codegen.h

Issue 1969423002: [Interpreter] Remove InterpreterExitTrampoline and replace with returning to the entry trampoline. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review comments Created 4 years, 7 months 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
« no previous file with comments | « src/full-codegen/arm64/full-codegen-arm64.cc ('k') | src/full-codegen/full-codegen.cc » ('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 // 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_FULL_CODEGEN_FULL_CODEGEN_H_ 5 #ifndef V8_FULL_CODEGEN_FULL_CODEGEN_H_
6 #define V8_FULL_CODEGEN_FULL_CODEGEN_H_ 6 #define V8_FULL_CODEGEN_FULL_CODEGEN_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/assert-scope.h" 9 #include "src/assert-scope.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
11 #include "src/ast/scopes.h" 11 #include "src/ast/scopes.h"
12 #include "src/bit-vector.h" 12 #include "src/bit-vector.h"
13 #include "src/code-factory.h" 13 #include "src/code-factory.h"
14 #include "src/code-stubs.h" 14 #include "src/code-stubs.h"
15 #include "src/codegen.h" 15 #include "src/codegen.h"
16 #include "src/compiler.h" 16 #include "src/compiler.h"
17 #include "src/deoptimizer.h"
17 #include "src/globals.h" 18 #include "src/globals.h"
18 #include "src/objects.h" 19 #include "src/objects.h"
19 20
20 namespace v8 { 21 namespace v8 {
21 namespace internal { 22 namespace internal {
22 23
23 // Forward declarations. 24 // Forward declarations.
24 class JumpPatchSite; 25 class JumpPatchSite;
25 26
26 // ----------------------------------------------------------------------------- 27 // -----------------------------------------------------------------------------
27 // Full code generator. 28 // Full code generator.
28 29
29 class FullCodeGenerator: public AstVisitor { 30 class FullCodeGenerator: public AstVisitor {
30 public: 31 public:
31 enum State {
32 NO_REGISTERS,
33 TOS_REG
34 };
35
36 FullCodeGenerator(MacroAssembler* masm, CompilationInfo* info) 32 FullCodeGenerator(MacroAssembler* masm, CompilationInfo* info)
37 : masm_(masm), 33 : masm_(masm),
38 info_(info), 34 info_(info),
39 isolate_(info->isolate()), 35 isolate_(info->isolate()),
40 zone_(info->zone()), 36 zone_(info->zone()),
41 scope_(info->scope()), 37 scope_(info->scope()),
42 nesting_stack_(NULL), 38 nesting_stack_(NULL),
43 loop_depth_(0), 39 loop_depth_(0),
44 try_catch_depth_(0), 40 try_catch_depth_(0),
45 operand_stack_depth_(0), 41 operand_stack_depth_(0),
46 globals_(NULL), 42 globals_(NULL),
47 context_(NULL), 43 context_(NULL),
48 bailout_entries_(info->HasDeoptimizationSupport() 44 bailout_entries_(info->HasDeoptimizationSupport()
49 ? info->literal()->ast_node_count() 45 ? info->literal()->ast_node_count()
50 : 0, 46 : 0,
51 info->zone()), 47 info->zone()),
52 back_edges_(2, info->zone()), 48 back_edges_(2, info->zone()),
53 handler_table_(info->zone()), 49 handler_table_(info->zone()),
54 ic_total_count_(0) { 50 ic_total_count_(0) {
55 DCHECK(!info->IsStub()); 51 DCHECK(!info->IsStub());
56 Initialize(); 52 Initialize();
57 } 53 }
58 54
59 void Initialize(); 55 void Initialize();
60 56
61 static bool MakeCode(CompilationInfo* info); 57 static bool MakeCode(CompilationInfo* info);
62 58
63 // Encode state and pc-offset as a BitField<type, start, size>. 59 // Encode bailout state and pc-offset as a BitField<type, start, size>.
64 // Only use 30 bits because we encode the result as a smi. 60 // Only use 30 bits because we encode the result as a smi.
65 class StateField : public BitField<State, 0, 1> { }; 61 class BailoutStateField : public BitField<Deoptimizer::BailoutState, 0, 1> {};
66 class PcField : public BitField<unsigned, 1, 30-1> { }; 62 class PcField : public BitField<unsigned, 1, 30 - 1> {};
67
68 static const char* State2String(State state) {
69 switch (state) {
70 case NO_REGISTERS: return "NO_REGISTERS";
71 case TOS_REG: return "TOS_REG";
72 }
73 UNREACHABLE();
74 return NULL;
75 }
76 63
77 static const int kMaxBackEdgeWeight = 127; 64 static const int kMaxBackEdgeWeight = 127;
78 65
79 // Platform-specific code size multiplier. 66 // Platform-specific code size multiplier.
80 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 67 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
81 static const int kCodeSizeMultiplier = 105; 68 static const int kCodeSizeMultiplier = 105;
82 #elif V8_TARGET_ARCH_X64 69 #elif V8_TARGET_ARCH_X64
83 static const int kCodeSizeMultiplier = 165; 70 static const int kCodeSizeMultiplier = 165;
84 #elif V8_TARGET_ARCH_ARM 71 #elif V8_TARGET_ARCH_ARM
85 static const int kCodeSizeMultiplier = 149; 72 static const int kCodeSizeMultiplier = 149;
(...skipping 13 matching lines...) Expand all
99 #elif V8_TARGET_ARCH_S390X 86 #elif V8_TARGET_ARCH_S390X
100 // TODO(joransiu): Copied PPC value. Check this is sensible for S390X. 87 // TODO(joransiu): Copied PPC value. Check this is sensible for S390X.
101 static const int kCodeSizeMultiplier = 200; 88 static const int kCodeSizeMultiplier = 200;
102 #else 89 #else
103 #error Unsupported target architecture. 90 #error Unsupported target architecture.
104 #endif 91 #endif
105 92
106 static Register result_register(); 93 static Register result_register();
107 94
108 private: 95 private:
96 typedef Deoptimizer::BailoutState BailoutState;
97
109 class Breakable; 98 class Breakable;
110 class Iteration; 99 class Iteration;
111 class TryFinally; 100 class TryFinally;
112 101
113 class TestContext; 102 class TestContext;
114 103
115 class NestedStatement BASE_EMBEDDED { 104 class NestedStatement BASE_EMBEDDED {
116 public: 105 public:
117 explicit NestedStatement(FullCodeGenerator* codegen) 106 explicit NestedStatement(FullCodeGenerator* codegen)
118 : codegen_(codegen), 107 : codegen_(codegen),
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // An operand used to read/write a known (PARAMETER, LOCAL, or CONTEXT) 348 // An operand used to read/write a known (PARAMETER, LOCAL, or CONTEXT)
360 // variable. May emit code to traverse the context chain, loading the 349 // variable. May emit code to traverse the context chain, loading the
361 // found context into the scratch register. Writing to this operand will 350 // found context into the scratch register. Writing to this operand will
362 // need the write barrier if location is CONTEXT. 351 // need the write barrier if location is CONTEXT.
363 MemOperand VarOperand(Variable* var, Register scratch); 352 MemOperand VarOperand(Variable* var, Register scratch);
364 353
365 void VisitForEffect(Expression* expr) { 354 void VisitForEffect(Expression* expr) {
366 if (FLAG_verify_operand_stack_depth) EmitOperandStackDepthCheck(); 355 if (FLAG_verify_operand_stack_depth) EmitOperandStackDepthCheck();
367 EffectContext context(this); 356 EffectContext context(this);
368 Visit(expr); 357 Visit(expr);
369 PrepareForBailout(expr, NO_REGISTERS); 358 PrepareForBailout(expr, BailoutState::NO_REGISTERS);
370 } 359 }
371 360
372 void VisitForAccumulatorValue(Expression* expr) { 361 void VisitForAccumulatorValue(Expression* expr) {
373 if (FLAG_verify_operand_stack_depth) EmitOperandStackDepthCheck(); 362 if (FLAG_verify_operand_stack_depth) EmitOperandStackDepthCheck();
374 AccumulatorValueContext context(this); 363 AccumulatorValueContext context(this);
375 Visit(expr); 364 Visit(expr);
376 PrepareForBailout(expr, TOS_REG); 365 PrepareForBailout(expr, BailoutState::TOS_REGISTER);
377 } 366 }
378 367
379 void VisitForStackValue(Expression* expr) { 368 void VisitForStackValue(Expression* expr) {
380 if (FLAG_verify_operand_stack_depth) EmitOperandStackDepthCheck(); 369 if (FLAG_verify_operand_stack_depth) EmitOperandStackDepthCheck();
381 StackValueContext context(this); 370 StackValueContext context(this);
382 Visit(expr); 371 Visit(expr);
383 PrepareForBailout(expr, NO_REGISTERS); 372 PrepareForBailout(expr, BailoutState::NO_REGISTERS);
384 } 373 }
385 374
386 void VisitForControl(Expression* expr, 375 void VisitForControl(Expression* expr,
387 Label* if_true, 376 Label* if_true,
388 Label* if_false, 377 Label* if_false,
389 Label* fall_through) { 378 Label* fall_through) {
390 if (FLAG_verify_operand_stack_depth) EmitOperandStackDepthCheck(); 379 if (FLAG_verify_operand_stack_depth) EmitOperandStackDepthCheck();
391 TestContext context(this, expr, if_true, if_false, fall_through); 380 TestContext context(this, expr, if_true, if_false, fall_through);
392 Visit(expr); 381 Visit(expr);
393 // For test contexts, we prepare for bailout before branching, not at 382 // For test contexts, we prepare for bailout before branching, not at
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 void EmitLiteralCompareTypeof(Expression* expr, 434 void EmitLiteralCompareTypeof(Expression* expr,
446 Expression* sub_expr, 435 Expression* sub_expr,
447 Handle<String> check); 436 Handle<String> check);
448 437
449 // Platform-specific code for equality comparison with a nil-like value. 438 // Platform-specific code for equality comparison with a nil-like value.
450 void EmitLiteralCompareNil(CompareOperation* expr, 439 void EmitLiteralCompareNil(CompareOperation* expr,
451 Expression* sub_expr, 440 Expression* sub_expr,
452 NilValue nil); 441 NilValue nil);
453 442
454 // Bailout support. 443 // Bailout support.
455 void PrepareForBailout(Expression* node, State state); 444 void PrepareForBailout(Expression* node, Deoptimizer::BailoutState state);
456 void PrepareForBailoutForId(BailoutId id, State state); 445 void PrepareForBailoutForId(BailoutId id, Deoptimizer::BailoutState state);
457 446
458 // Returns a smi for the index into the FixedArray that backs the feedback 447 // Returns a smi for the index into the FixedArray that backs the feedback
459 // vector 448 // vector
460 Smi* SmiFromSlot(FeedbackVectorSlot slot) const { 449 Smi* SmiFromSlot(FeedbackVectorSlot slot) const {
461 return Smi::FromInt(TypeFeedbackVector::GetIndexFromSpec( 450 return Smi::FromInt(TypeFeedbackVector::GetIndexFromSpec(
462 literal()->feedback_vector_spec(), slot)); 451 literal()->feedback_vector_spec(), slot));
463 } 452 }
464 453
465 // Record a call's return site offset, used to rebuild the frame if the 454 // Record a call's return site offset, used to rebuild the frame if the
466 // called function was inlined at the site. 455 // called function was inlined at the site.
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 Address start_; 1059 Address start_;
1071 Address instruction_start_; 1060 Address instruction_start_;
1072 uint32_t length_; 1061 uint32_t length_;
1073 }; 1062 };
1074 1063
1075 1064
1076 } // namespace internal 1065 } // namespace internal
1077 } // namespace v8 1066 } // namespace v8
1078 1067
1079 #endif // V8_FULL_CODEGEN_FULL_CODEGEN_H_ 1068 #endif // V8_FULL_CODEGEN_FULL_CODEGEN_H_
OLDNEW
« no previous file with comments | « src/full-codegen/arm64/full-codegen-arm64.cc ('k') | src/full-codegen/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698