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

Side by Side Diff: src/compiler.h

Issue 651031: Begin using a list of bailouts instead of a singleton in the fast code generator. (Closed)
Patch Set: Created 10 years, 10 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 23 matching lines...) Expand all
34 #include "register-allocator.h" 34 #include "register-allocator.h"
35 #include "zone.h" 35 #include "zone.h"
36 36
37 namespace v8 { 37 namespace v8 {
38 namespace internal { 38 namespace internal {
39 39
40 // CompilationInfo encapsulates some information known at compile time. It 40 // CompilationInfo encapsulates some information known at compile time. It
41 // is constructed based on the resources available at compile-time. 41 // is constructed based on the resources available at compile-time.
42 class CompilationInfo BASE_EMBEDDED { 42 class CompilationInfo BASE_EMBEDDED {
43 public: 43 public:
44 // Compilation mode. Either the compiler is used as the primary
45 // compiler and needs to setup everything or the compiler is used as
46 // the secondary compiler for split compilation and has to handle
47 // bailouts.
48 enum Mode {
49 PRIMARY,
50 SECONDARY
51 };
52
53 // A description of the compilation state at a bailout to the secondary
54 // code generator.
55 //
56 // The state is currently simple: there are no parameters or local
57 // variables to worry about ('this' can be found in the stack frame).
58 // There are at most two live values.
59 //
60 // There is a label that should be bound to the beginning of the bailout
61 // stub code.
62 class Bailout : public ZoneObject {
63 public:
64 Bailout(Register left, Register right) : left_(left), right_(right) {}
fschneider 2010/02/19 14:47:14 label_ needs to be initialized here.
65
66 Label* label() { return &label_; }
67
68 private:
69 Register left_;
70 Register right_;
71 Label label_;
72 };
73
74
44 // Lazy compilation of a JSFunction. 75 // Lazy compilation of a JSFunction.
45 CompilationInfo(Handle<JSFunction> closure, 76 CompilationInfo(Handle<JSFunction> closure,
46 int loop_nesting, 77 int loop_nesting,
47 Handle<Object> receiver) 78 Handle<Object> receiver)
48 : closure_(closure), 79 : closure_(closure),
49 function_(NULL), 80 function_(NULL),
50 is_eval_(false), 81 is_eval_(false),
51 loop_nesting_(loop_nesting), 82 loop_nesting_(loop_nesting),
52 receiver_(receiver) { 83 receiver_(receiver) {
53 Initialize(); 84 Initialize();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void set_function(FunctionLiteral* literal) { 141 void set_function(FunctionLiteral* literal) {
111 ASSERT(function_ == NULL); 142 ASSERT(function_ == NULL);
112 function_ = literal; 143 function_ = literal;
113 } 144 }
114 145
115 // Simple accessors. 146 // Simple accessors.
116 bool is_eval() { return is_eval_; } 147 bool is_eval() { return is_eval_; }
117 int loop_nesting() { return loop_nesting_; } 148 int loop_nesting() { return loop_nesting_; }
118 bool has_receiver() { return !receiver_.is_null(); } 149 bool has_receiver() { return !receiver_.is_null(); }
119 Handle<Object> receiver() { return receiver_; } 150 Handle<Object> receiver() { return receiver_; }
151 List<Bailout*>* bailouts() { return &bailouts_; }
120 152
121 // Accessors for mutable fields, possibly set by analysis passes with 153 // Accessors for mutable fields (possibly set by analysis passes) with
122 // default values given by Initialize. 154 // default values given by Initialize.
155 Mode mode() { return mode_; }
156 void set_mode(Mode mode) { mode_ = mode; }
157
123 bool has_this_properties() { return has_this_properties_; } 158 bool has_this_properties() { return has_this_properties_; }
124 void set_has_this_properties(bool flag) { has_this_properties_ = flag; } 159 void set_has_this_properties(bool flag) { has_this_properties_ = flag; }
125 160
126 bool has_global_object() { 161 bool has_global_object() {
127 return !closure().is_null() && (closure()->context()->global() != NULL); 162 return !closure().is_null() && (closure()->context()->global() != NULL);
128 } 163 }
129 164
130 GlobalObject* global_object() { 165 GlobalObject* global_object() {
131 return has_global_object() ? closure()->context()->global() : NULL; 166 return has_global_object() ? closure()->context()->global() : NULL;
132 } 167 }
133 168
134 bool has_globals() { return has_globals_; } 169 bool has_globals() { return has_globals_; }
135 void set_has_globals(bool flag) { has_globals_ = flag; } 170 void set_has_globals(bool flag) { has_globals_ = flag; }
136 171
137 // Derived accessors. 172 // Derived accessors.
138 Scope* scope() { return function()->scope(); } 173 Scope* scope() { return function()->scope(); }
139 174
175 // Add a bailout with two live values.
176 Label* AddBailout(Register left, Register right) {
177 Bailout* bailout = new Bailout(left, right);
178 bailouts_.Add(bailout);
179 return bailout->label();
180 }
181
182 // Add a bailout with no live values.
183 Label* AddBailout() { return AddBailout(no_reg, no_reg); }
184
140 private: 185 private:
141 void Initialize() { 186 void Initialize() {
187 mode_ = PRIMARY;
142 has_this_properties_ = false; 188 has_this_properties_ = false;
143 has_globals_ = false; 189 has_globals_ = false;
144 } 190 }
145 191
146 Handle<JSFunction> closure_; 192 Handle<JSFunction> closure_;
147 Handle<SharedFunctionInfo> shared_info_; 193 Handle<SharedFunctionInfo> shared_info_;
148 Handle<Script> script_; 194 Handle<Script> script_;
149 195
150 FunctionLiteral* function_; 196 FunctionLiteral* function_;
197 Mode mode_;
151 198
152 bool is_eval_; 199 bool is_eval_;
153 int loop_nesting_; 200 int loop_nesting_;
154 201
155 Handle<Object> receiver_; 202 Handle<Object> receiver_;
156 203
157 bool has_this_properties_; 204 bool has_this_properties_;
158 bool has_globals_; 205 bool has_globals_;
159 206
207 // An ordered list of bailout points encountered during fast-path
208 // compilation.
209 List<Bailout*> bailouts_;
210
160 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); 211 DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
161 }; 212 };
162 213
163 214
164 // The V8 compiler 215 // The V8 compiler
165 // 216 //
166 // General strategy: Source code is translated into an anonymous function w/o 217 // General strategy: Source code is translated into an anonymous function w/o
167 // parameters which then can be executed. If the source code contains other 218 // parameters which then can be executed. If the source code contains other
168 // functions, they will be compiled and allocated as part of the compilation 219 // functions, they will be compiled and allocated as part of the compilation
169 // of the source code. 220 // of the source code.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 FrameElement::ClearConstantList(); 287 FrameElement::ClearConstantList();
237 Result::ClearConstantList(); 288 Result::ClearConstantList();
238 } 289 }
239 } 290 }
240 }; 291 };
241 292
242 293
243 } } // namespace v8::internal 294 } } // namespace v8::internal
244 295
245 #endif // V8_COMPILER_H_ 296 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « src/codegen.cc ('k') | src/fast-codegen.h » ('j') | src/ia32/fast-codegen-ia32.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698