OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 private: | 138 private: |
139 CodeGenerator* owner_; | 139 CodeGenerator* owner_; |
140 JumpTarget* true_target_; | 140 JumpTarget* true_target_; |
141 JumpTarget* false_target_; | 141 JumpTarget* false_target_; |
142 CodeGenState* previous_; | 142 CodeGenState* previous_; |
143 }; | 143 }; |
144 | 144 |
145 | 145 |
146 // ------------------------------------------------------------------------- | 146 // ------------------------------------------------------------------------- |
| 147 // Arguments allocation mode |
| 148 |
| 149 enum ArgumentsAllocationMode { |
| 150 NO_ARGUMENTS_ALLOCATION, |
| 151 EAGER_ARGUMENTS_ALLOCATION, |
| 152 LAZY_ARGUMENTS_ALLOCATION |
| 153 }; |
| 154 |
| 155 |
| 156 // ------------------------------------------------------------------------- |
147 // CodeGenerator | 157 // CodeGenerator |
148 | 158 |
149 class CodeGenerator: public AstVisitor { | 159 class CodeGenerator: public AstVisitor { |
150 public: | 160 public: |
151 // Takes a function literal, generates code for it. This function should only | 161 // Takes a function literal, generates code for it. This function should only |
152 // be called by compiler.cc. | 162 // be called by compiler.cc. |
153 static Handle<Code> MakeCode(CompilationInfo* info); | 163 static Handle<Code> MakeCode(CompilationInfo* info); |
154 | 164 |
155 // Printing of AST, etc. as requested by flags. | 165 // Printing of AST, etc. as requested by flags. |
156 static void MakeCodePrologue(CompilationInfo* info); | 166 static void MakeCodePrologue(CompilationInfo* info); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // the code generator is being transformed. | 244 // the code generator is being transformed. |
235 inline void VisitAndSpill(Statement* statement); | 245 inline void VisitAndSpill(Statement* statement); |
236 | 246 |
237 // Visit a list of statements and then spill the virtual frame if control | 247 // Visit a list of statements and then spill the virtual frame if control |
238 // flow can reach the end of the list. | 248 // flow can reach the end of the list. |
239 inline void VisitStatementsAndSpill(ZoneList<Statement*>* statements); | 249 inline void VisitStatementsAndSpill(ZoneList<Statement*>* statements); |
240 | 250 |
241 // Main code generation function | 251 // Main code generation function |
242 void Generate(CompilationInfo* info); | 252 void Generate(CompilationInfo* info); |
243 | 253 |
| 254 // Returns the arguments allocation mode. |
| 255 ArgumentsAllocationMode ArgumentsMode(); |
| 256 |
| 257 // Store the arguments object and allocate it if necessary. |
| 258 void StoreArgumentsObject(bool initial); |
| 259 |
244 // The following are used by class Reference. | 260 // The following are used by class Reference. |
245 void LoadReference(Reference* ref); | 261 void LoadReference(Reference* ref); |
246 void UnloadReference(Reference* ref); | 262 void UnloadReference(Reference* ref); |
247 | 263 |
248 static MemOperand ContextOperand(Register context, int index) { | 264 static MemOperand ContextOperand(Register context, int index) { |
249 return MemOperand(context, Context::SlotOffset(index)); | 265 return MemOperand(context, Context::SlotOffset(index)); |
250 } | 266 } |
251 | 267 |
252 MemOperand SlotOperand(Slot* slot, Register tmp); | 268 MemOperand SlotOperand(Slot* slot, Register tmp); |
253 | 269 |
(...skipping 23 matching lines...) Expand all Loading... |
277 // Call LoadCondition and then spill the virtual frame unless control flow | 293 // Call LoadCondition and then spill the virtual frame unless control flow |
278 // cannot reach the end of the expression (ie, by emitting only | 294 // cannot reach the end of the expression (ie, by emitting only |
279 // unconditional jumps to the control targets). | 295 // unconditional jumps to the control targets). |
280 inline void LoadConditionAndSpill(Expression* expression, | 296 inline void LoadConditionAndSpill(Expression* expression, |
281 JumpTarget* true_target, | 297 JumpTarget* true_target, |
282 JumpTarget* false_target, | 298 JumpTarget* false_target, |
283 bool force_control); | 299 bool force_control); |
284 | 300 |
285 // Read a value from a slot and leave it on top of the expression stack. | 301 // Read a value from a slot and leave it on top of the expression stack. |
286 void LoadFromSlot(Slot* slot, TypeofState typeof_state); | 302 void LoadFromSlot(Slot* slot, TypeofState typeof_state); |
| 303 void LoadFromSlotCheckForArguments(Slot* slot, TypeofState state); |
287 // Store the value on top of the stack to a slot. | 304 // Store the value on top of the stack to a slot. |
288 void StoreToSlot(Slot* slot, InitState init_state); | 305 void StoreToSlot(Slot* slot, InitState init_state); |
289 | 306 |
290 // Load a named property, leaving it in r0. The receiver is passed on the | 307 // Load a named property, leaving it in r0. The receiver is passed on the |
291 // stack, and remain there. | 308 // stack, and remain there. |
292 void EmitNamedLoad(Handle<String> name, bool is_contextual); | 309 void EmitNamedLoad(Handle<String> name, bool is_contextual); |
293 | 310 |
294 // Load a keyed property, leaving it in r0. The receiver and key are | 311 // Load a keyed property, leaving it in r0. The receiver and key are |
295 // passed on the stack, and remain there. | 312 // passed on the stack, and remain there. |
296 void EmitKeyedLoad(bool is_global); | 313 void EmitKeyedLoad(bool is_global); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 | 349 |
333 void VirtualFrameSmiOperation(Token::Value op, | 350 void VirtualFrameSmiOperation(Token::Value op, |
334 Handle<Object> value, | 351 Handle<Object> value, |
335 bool reversed, | 352 bool reversed, |
336 OverwriteMode mode); | 353 OverwriteMode mode); |
337 | 354 |
338 void CallWithArguments(ZoneList<Expression*>* arguments, | 355 void CallWithArguments(ZoneList<Expression*>* arguments, |
339 CallFunctionFlags flags, | 356 CallFunctionFlags flags, |
340 int position); | 357 int position); |
341 | 358 |
| 359 // An optimized implementation of expressions of the form |
| 360 // x.apply(y, arguments). We call x the applicand and y the receiver. |
| 361 // The optimization avoids allocating an arguments object if possible. |
| 362 void CallApplyLazy(Expression* applicand, |
| 363 Expression* receiver, |
| 364 VariableProxy* arguments, |
| 365 int position); |
| 366 |
342 // Control flow | 367 // Control flow |
343 void Branch(bool if_true, JumpTarget* target); | 368 void Branch(bool if_true, JumpTarget* target); |
344 void CheckStack(); | 369 void CheckStack(); |
345 | 370 |
346 struct InlineRuntimeLUT { | 371 struct InlineRuntimeLUT { |
347 void (CodeGenerator::*method)(ZoneList<Expression*>*); | 372 void (CodeGenerator::*method)(ZoneList<Expression*>*); |
348 const char* name; | 373 const char* name; |
349 int nargs; | 374 int nargs; |
350 }; | 375 }; |
351 | 376 |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 void Print() { | 846 void Print() { |
822 PrintF("NumberToStringStub\n"); | 847 PrintF("NumberToStringStub\n"); |
823 } | 848 } |
824 #endif | 849 #endif |
825 }; | 850 }; |
826 | 851 |
827 | 852 |
828 } } // namespace v8::internal | 853 } } // namespace v8::internal |
829 | 854 |
830 #endif // V8_ARM_CODEGEN_ARM_H_ | 855 #endif // V8_ARM_CODEGEN_ARM_H_ |
OLD | NEW |