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

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

Issue 804463002: Stack-allocate block variables (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: moar progress Created 6 years 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/compiler/ast-graph-builder.cc ('k') | src/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_H_ 5 #ifndef V8_FULL_CODEGEN_H_
6 #define V8_FULL_CODEGEN_H_ 6 #define V8_FULL_CODEGEN_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
11 #include "src/assert-scope.h" 11 #include "src/assert-scope.h"
12 #include "src/ast.h" 12 #include "src/ast.h"
13 #include "src/bit-vector.h" 13 #include "src/bit-vector.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/globals.h" 17 #include "src/globals.h"
18 #include "src/objects.h" 18 #include "src/objects.h"
19 #include "src/scopes.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 // AST node visitor which can tell whether a given statement will be breakable 27 // AST node visitor which can tell whether a given statement will be breakable
27 // when the code is compiled by the full compiler in the debugger. This means 28 // when the code is compiled by the full compiler in the debugger. This means
28 // that there will be an IC (load/store/call) in the code generated for the 29 // that there will be an IC (load/store/call) in the code generated for the
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 210
210 // A nested block statement. 211 // A nested block statement.
211 class NestedBlock : public Breakable { 212 class NestedBlock : public Breakable {
212 public: 213 public:
213 NestedBlock(FullCodeGenerator* codegen, Block* block) 214 NestedBlock(FullCodeGenerator* codegen, Block* block)
214 : Breakable(codegen, block) { 215 : Breakable(codegen, block) {
215 } 216 }
216 virtual ~NestedBlock() {} 217 virtual ~NestedBlock() {}
217 218
218 virtual NestedStatement* Exit(int* stack_depth, int* context_length) { 219 virtual NestedStatement* Exit(int* stack_depth, int* context_length) {
219 if (statement()->AsBlock()->scope() != NULL) { 220 Scope* block_scope = statement()->AsBlock()->scope();
221 if (block_scope != nullptr && block_scope->ContextLocalCount() > 0) {
220 ++(*context_length); 222 ++(*context_length);
221 } 223 }
224 if (block_scope != nullptr) {
225 *stack_depth += block_scope->num_stack_slots();
226 }
222 return previous_; 227 return previous_;
223 } 228 }
224 }; 229 };
225 230
226 // The try block of a try/catch statement. 231 // The try block of a try/catch statement.
227 class TryCatch : public NestedStatement { 232 class TryCatch : public NestedStatement {
228 public: 233 public:
229 explicit TryCatch(FullCodeGenerator* codegen) : NestedStatement(codegen) { 234 explicit TryCatch(FullCodeGenerator* codegen) : NestedStatement(codegen) {
230 } 235 }
231 virtual ~TryCatch() {} 236 virtual ~TryCatch() {}
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 public: 904 public:
900 EnterBlockScopeIfNeeded(FullCodeGenerator* codegen, Scope* scope, 905 EnterBlockScopeIfNeeded(FullCodeGenerator* codegen, Scope* scope,
901 BailoutId entry_id, BailoutId declarations_id, 906 BailoutId entry_id, BailoutId declarations_id,
902 BailoutId exit_id); 907 BailoutId exit_id);
903 ~EnterBlockScopeIfNeeded(); 908 ~EnterBlockScopeIfNeeded();
904 909
905 private: 910 private:
906 MacroAssembler* masm() const { return codegen_->masm(); } 911 MacroAssembler* masm() const { return codegen_->masm(); }
907 912
908 FullCodeGenerator* codegen_; 913 FullCodeGenerator* codegen_;
909 Scope* scope_;
910 Scope* saved_scope_; 914 Scope* saved_scope_;
911 BailoutId exit_id_; 915 BailoutId exit_id_;
916 bool needs_block_context_;
917 bool num_stack_slots_;
912 }; 918 };
913 919
920 void AllocateLocals(int local_count);
921 void DeallocateLocals(int local_count);
922
914 MacroAssembler* masm_; 923 MacroAssembler* masm_;
915 CompilationInfo* info_; 924 CompilationInfo* info_;
916 Scope* scope_; 925 Scope* scope_;
917 Label return_label_; 926 Label return_label_;
918 NestedStatement* nesting_stack_; 927 NestedStatement* nesting_stack_;
919 int loop_depth_; 928 int loop_depth_;
920 ZoneList<Handle<Object> >* globals_; 929 ZoneList<Handle<Object> >* globals_;
921 Handle<FixedArray> modules_; 930 Handle<FixedArray> modules_;
922 int module_index_; 931 int module_index_;
923 const ExpressionContext* context_; 932 const ExpressionContext* context_;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 1045
1037 Address start_; 1046 Address start_;
1038 Address instruction_start_; 1047 Address instruction_start_;
1039 uint32_t length_; 1048 uint32_t length_;
1040 }; 1049 };
1041 1050
1042 1051
1043 } } // namespace v8::internal 1052 } } // namespace v8::internal
1044 1053
1045 #endif // V8_FULL_CODEGEN_H_ 1054 #endif // V8_FULL_CODEGEN_H_
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698