diff options
Diffstat (limited to 'deps/v8/src/full-codegen/full-codegen.h')
-rw-r--r-- | deps/v8/src/full-codegen/full-codegen.h | 106 |
1 files changed, 42 insertions, 64 deletions
diff --git a/deps/v8/src/full-codegen/full-codegen.h b/deps/v8/src/full-codegen/full-codegen.h index 6ab02313bb..0c12937149 100644 --- a/deps/v8/src/full-codegen/full-codegen.h +++ b/deps/v8/src/full-codegen/full-codegen.h @@ -93,6 +93,12 @@ class FullCodeGenerator: public AstVisitor { static const int kCodeSizeMultiplier = 149; #elif V8_TARGET_ARCH_MIPS64 static const int kCodeSizeMultiplier = 149; +#elif V8_TARGET_ARCH_S390 +// TODO(joransiu): Copied PPC value. Check this is sensible for S390. + static const int kCodeSizeMultiplier = 200; +#elif V8_TARGET_ARCH_S390X +// TODO(joransiu): Copied PPC value. Check this is sensible for S390X. + static const int kCodeSizeMultiplier = 200; #else #error Unsupported target architecture. #endif @@ -108,7 +114,9 @@ class FullCodeGenerator: public AstVisitor { class NestedStatement BASE_EMBEDDED { public: - explicit NestedStatement(FullCodeGenerator* codegen) : codegen_(codegen) { + explicit NestedStatement(FullCodeGenerator* codegen) + : codegen_(codegen), + stack_depth_at_target_(codegen->operand_stack_depth_) { // Link into codegen's nesting stack. previous_ = codegen->nesting_stack_; codegen->nesting_stack_ = this; @@ -130,18 +138,20 @@ class FullCodeGenerator: public AstVisitor { // Notify the statement that we are exiting it via break, continue, or // return and give it a chance to generate cleanup code. Return the // next outer statement in the nesting stack. We accumulate in - // *stack_depth the amount to drop the stack and in *context_length the - // number of context chain links to unwind as we traverse the nesting - // stack from an exit to its target. - virtual NestedStatement* Exit(int* stack_depth, int* context_length) { - return previous_; - } + // {*context_length} the number of context chain links to unwind as we + // traverse the nesting stack from an exit to its target. + virtual NestedStatement* Exit(int* context_length) { return previous_; } + + // Determine the expected operand stack depth when this statement is being + // used as the target of an exit. The caller will drop to this depth. + int GetStackDepthAtTarget() { return stack_depth_at_target_; } protected: MacroAssembler* masm() { return codegen_->masm(); } FullCodeGenerator* codegen_; NestedStatement* previous_; + int stack_depth_at_target_; private: DISALLOW_COPY_AND_ASSIGN(NestedStatement); @@ -192,7 +202,7 @@ class FullCodeGenerator: public AstVisitor { : Breakable(codegen, block) { } - NestedStatement* Exit(int* stack_depth, int* context_length) override { + NestedStatement* Exit(int* context_length) override { auto block_scope = statement()->AsBlock()->scope(); if (block_scope != nullptr) { if (block_scope->ContextLocalCount() > 0) ++(*context_length); @@ -201,17 +211,21 @@ class FullCodeGenerator: public AstVisitor { } }; - // The try block of a try/catch statement. - class TryCatch : public NestedStatement { + // A class literal expression + class NestedClassLiteral : public NestedStatement { public: - static const int kElementCount = TryBlockConstant::kElementCount; - - explicit TryCatch(FullCodeGenerator* codegen) : NestedStatement(codegen) {} + NestedClassLiteral(FullCodeGenerator* codegen, ClassLiteral* lit) + : NestedStatement(codegen), + needs_context_(lit->scope() != nullptr && + lit->scope()->NeedsContext()) {} - NestedStatement* Exit(int* stack_depth, int* context_length) override { - *stack_depth += kElementCount; + NestedStatement* Exit(int* context_length) override { + if (needs_context_) ++(*context_length); return previous_; } + + private: + const bool needs_context_; }; class DeferredCommands { @@ -254,12 +268,10 @@ class FullCodeGenerator: public AstVisitor { // The try block of a try/finally statement. class TryFinally : public NestedStatement { public: - static const int kElementCount = TryBlockConstant::kElementCount; - TryFinally(FullCodeGenerator* codegen, DeferredCommands* commands) : NestedStatement(codegen), deferred_commands_(commands) {} - NestedStatement* Exit(int* stack_depth, int* context_length) override; + NestedStatement* Exit(int* context_length) override; bool IsTryFinally() override { return true; } TryFinally* AsTryFinally() override { return this; } @@ -270,35 +282,6 @@ class FullCodeGenerator: public AstVisitor { DeferredCommands* deferred_commands_; }; - // The finally block of a try/finally statement. - class Finally : public NestedStatement { - public: - static const int kElementCount = 3; - - explicit Finally(FullCodeGenerator* codegen) : NestedStatement(codegen) {} - - NestedStatement* Exit(int* stack_depth, int* context_length) override { - *stack_depth += kElementCount; - return previous_; - } - }; - - // The body of a for/in loop. - class ForIn : public Iteration { - public: - static const int kElementCount = 5; - - ForIn(FullCodeGenerator* codegen, ForInStatement* statement) - : Iteration(codegen, statement) { - } - - NestedStatement* Exit(int* stack_depth, int* context_length) override { - *stack_depth += kElementCount; - return previous_; - } - }; - - // The body of a with or catch. class WithOrCatch : public NestedStatement { public: @@ -306,7 +289,7 @@ class FullCodeGenerator: public AstVisitor { : NestedStatement(codegen) { } - NestedStatement* Exit(int* stack_depth, int* context_length) override { + NestedStatement* Exit(int* context_length) override { ++(*context_length); return previous_; } @@ -537,6 +520,7 @@ class FullCodeGenerator: public AstVisitor { F(IsRegExp) \ F(IsJSProxy) \ F(Call) \ + F(NewObject) \ F(ValueOf) \ F(StringCharFromCode) \ F(StringCharAt) \ @@ -564,6 +548,7 @@ class FullCodeGenerator: public AstVisitor { F(ToName) \ F(ToObject) \ F(DebugIsActive) \ + F(GetOrdinaryHasInstance) \ F(CreateIterResultObject) #define GENERATOR_DECLARATION(Name) void Emit##Name(CallRuntime* call); @@ -681,6 +666,8 @@ class FullCodeGenerator: public AstVisitor { void EmitSetHomeObjectAccumulator(Expression* initializer, int offset, FeedbackVectorSlot slot); + void EmitLoadStoreICSlot(FeedbackVectorSlot slot); + void CallIC(Handle<Code> code, TypeFeedbackId id = TypeFeedbackId::None()); @@ -707,7 +694,8 @@ class FullCodeGenerator: public AstVisitor { // This is used in loop headers where we want to break for each iteration. void SetExpressionAsStatementPosition(Expression* expr); - void SetCallPosition(Expression* expr); + void SetCallPosition(Expression* expr, + TailCallMode tail_call_mode = TailCallMode::kDisallow); void SetConstructCallPosition(Expression* expr) { // Currently call and construct calls are treated the same wrt debugging. @@ -743,13 +731,16 @@ class FullCodeGenerator: public AstVisitor { Handle<Script> script() { return info_->script(); } bool is_eval() { return info_->is_eval(); } bool is_native() { return info_->is_native(); } - LanguageMode language_mode() { return literal()->language_mode(); } + LanguageMode language_mode() { return scope()->language_mode(); } bool has_simple_parameters() { return info_->has_simple_parameters(); } FunctionLiteral* literal() const { return info_->literal(); } Scope* scope() { return scope_; } static Register context_register(); + // Get fields from the stack frame. Offsets are the frame pointer relative + // offsets defined in, e.g., StandardFrameConstants. + void LoadFromFrameField(int frame_offset, Register value); // Set fields in the stack frame. Offsets are the frame pointer relative // offsets defined in, e.g., StandardFrameConstants. void StoreToFrameField(int frame_offset, Register value); @@ -783,8 +774,6 @@ class FullCodeGenerator: public AstVisitor { bool MustCreateObjectLiteralWithRuntime(ObjectLiteral* expr) const; bool MustCreateArrayLiteralWithRuntime(ArrayLiteral* expr) const; - void EmitLoadStoreICSlot(FeedbackVectorSlot slot); - int NewHandlerTableEntry(); struct BailoutEntry { @@ -1046,11 +1035,7 @@ class BackEdgeTable { return instruction_start_ + pc_offset(index); } - enum BackEdgeState { - INTERRUPT, - ON_STACK_REPLACEMENT, - OSR_AFTER_STACK_CHECK - }; + enum BackEdgeState { INTERRUPT, ON_STACK_REPLACEMENT }; // Increase allowed loop nesting level by one and patch those matching loops. static void Patch(Isolate* isolate, Code* unoptimized_code); @@ -1065,13 +1050,6 @@ class BackEdgeTable { static void Revert(Isolate* isolate, Code* unoptimized_code); - // Change a back edge patched for on-stack replacement to perform a - // stack check first. - static void AddStackCheck(Handle<Code> code, uint32_t pc_offset); - - // Revert the patch by AddStackCheck. - static void RemoveStackCheck(Handle<Code> code, uint32_t pc_offset); - // Return the current patch state of the back edge. static BackEdgeState GetBackEdgeState(Isolate* isolate, Code* unoptimized_code, |