| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 JumpTarget* false_target_; | 143 JumpTarget* false_target_; |
| 144 CodeGenState* previous_; | 144 CodeGenState* previous_; |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 | 147 |
| 148 // ------------------------------------------------------------------------- | 148 // ------------------------------------------------------------------------- |
| 149 // CodeGenerator | 149 // CodeGenerator |
| 150 | 150 |
| 151 class CodeGenerator: public AstVisitor { | 151 class CodeGenerator: public AstVisitor { |
| 152 public: | 152 public: |
| 153 // Compilation mode. Either the compiler is used as the primary | |
| 154 // compiler and needs to setup everything or the compiler is used as | |
| 155 // the secondary compiler for split compilation and has to handle | |
| 156 // bailouts. | |
| 157 enum Mode { | |
| 158 PRIMARY, | |
| 159 SECONDARY | |
| 160 }; | |
| 161 | |
| 162 // Takes a function literal, generates code for it. This function should only | 153 // Takes a function literal, generates code for it. This function should only |
| 163 // be called by compiler.cc. | 154 // be called by compiler.cc. |
| 164 static Handle<Code> MakeCode(CompilationInfo* info); | 155 static Handle<Code> MakeCode(CompilationInfo* info); |
| 165 | 156 |
| 166 // Printing of AST, etc. as requested by flags. | 157 // Printing of AST, etc. as requested by flags. |
| 167 static void MakeCodePrologue(CompilationInfo* info); | 158 static void MakeCodePrologue(CompilationInfo* info); |
| 168 | 159 |
| 169 // Allocate and install the code. | 160 // Allocate and install the code. |
| 170 static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm, | 161 static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm, |
| 171 Code::Flags flags, | 162 Code::Flags flags, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // reach the end of the statement (ie, it does not exit via break, | 228 // reach the end of the statement (ie, it does not exit via break, |
| 238 // continue, return, or throw). This function is used temporarily while | 229 // continue, return, or throw). This function is used temporarily while |
| 239 // the code generator is being transformed. | 230 // the code generator is being transformed. |
| 240 inline void VisitAndSpill(Statement* statement); | 231 inline void VisitAndSpill(Statement* statement); |
| 241 | 232 |
| 242 // Visit a list of statements and then spill the virtual frame if control | 233 // Visit a list of statements and then spill the virtual frame if control |
| 243 // flow can reach the end of the list. | 234 // flow can reach the end of the list. |
| 244 inline void VisitStatementsAndSpill(ZoneList<Statement*>* statements); | 235 inline void VisitStatementsAndSpill(ZoneList<Statement*>* statements); |
| 245 | 236 |
| 246 // Main code generation function | 237 // Main code generation function |
| 247 void Generate(CompilationInfo* info, Mode mode); | 238 void Generate(CompilationInfo* info); |
| 248 | 239 |
| 249 // The following are used by class Reference. | 240 // The following are used by class Reference. |
| 250 void LoadReference(Reference* ref); | 241 void LoadReference(Reference* ref); |
| 251 void UnloadReference(Reference* ref); | 242 void UnloadReference(Reference* ref); |
| 252 | 243 |
| 253 static MemOperand ContextOperand(Register context, int index) { | 244 static MemOperand ContextOperand(Register context, int index) { |
| 254 return MemOperand(context, Context::SlotOffset(index)); | 245 return MemOperand(context, Context::SlotOffset(index)); |
| 255 } | 246 } |
| 256 | 247 |
| 257 MemOperand SlotOperand(Slot* slot, Register tmp); | 248 MemOperand SlotOperand(Slot* slot, Register tmp); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 // name/value pairs. | 343 // name/value pairs. |
| 353 void DeclareGlobals(Handle<FixedArray> pairs); | 344 void DeclareGlobals(Handle<FixedArray> pairs); |
| 354 | 345 |
| 355 // Instantiate the function boilerplate. | 346 // Instantiate the function boilerplate. |
| 356 void InstantiateBoilerplate(Handle<JSFunction> boilerplate); | 347 void InstantiateBoilerplate(Handle<JSFunction> boilerplate); |
| 357 | 348 |
| 358 // Support for type checks. | 349 // Support for type checks. |
| 359 void GenerateIsSmi(ZoneList<Expression*>* args); | 350 void GenerateIsSmi(ZoneList<Expression*>* args); |
| 360 void GenerateIsNonNegativeSmi(ZoneList<Expression*>* args); | 351 void GenerateIsNonNegativeSmi(ZoneList<Expression*>* args); |
| 361 void GenerateIsArray(ZoneList<Expression*>* args); | 352 void GenerateIsArray(ZoneList<Expression*>* args); |
| 353 void GenerateIsRegExp(ZoneList<Expression*>* args); |
| 362 void GenerateIsObject(ZoneList<Expression*>* args); | 354 void GenerateIsObject(ZoneList<Expression*>* args); |
| 363 void GenerateIsFunction(ZoneList<Expression*>* args); | 355 void GenerateIsFunction(ZoneList<Expression*>* args); |
| 364 void GenerateIsUndetectableObject(ZoneList<Expression*>* args); | 356 void GenerateIsUndetectableObject(ZoneList<Expression*>* args); |
| 365 | 357 |
| 366 // Support for construct call checks. | 358 // Support for construct call checks. |
| 367 void GenerateIsConstructCall(ZoneList<Expression*>* args); | 359 void GenerateIsConstructCall(ZoneList<Expression*>* args); |
| 368 | 360 |
| 369 // Support for arguments.length and arguments[?]. | 361 // Support for arguments.length and arguments[?]. |
| 370 void GenerateArgumentsLength(ZoneList<Expression*>* args); | 362 void GenerateArgumentsLength(ZoneList<Expression*>* args); |
| 371 void GenerateArgumentsAccess(ZoneList<Expression*>* args); | 363 void GenerateArgumentsAccess(ZoneList<Expression*>* args); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 391 | 383 |
| 392 // Fast support for SubString. | 384 // Fast support for SubString. |
| 393 void GenerateSubString(ZoneList<Expression*>* args); | 385 void GenerateSubString(ZoneList<Expression*>* args); |
| 394 | 386 |
| 395 // Fast support for StringCompare. | 387 // Fast support for StringCompare. |
| 396 void GenerateStringCompare(ZoneList<Expression*>* args); | 388 void GenerateStringCompare(ZoneList<Expression*>* args); |
| 397 | 389 |
| 398 // Support for direct calls from JavaScript to native RegExp code. | 390 // Support for direct calls from JavaScript to native RegExp code. |
| 399 void GenerateRegExpExec(ZoneList<Expression*>* args); | 391 void GenerateRegExpExec(ZoneList<Expression*>* args); |
| 400 | 392 |
| 393 // Fast support for number to string. |
| 394 void GenerateNumberToString(ZoneList<Expression*>* args); |
| 395 |
| 396 // Fast call to sine function. |
| 397 void GenerateMathSin(ZoneList<Expression*>* args); |
| 398 void GenerateMathCos(ZoneList<Expression*>* args); |
| 399 |
| 401 // Simple condition analysis. | 400 // Simple condition analysis. |
| 402 enum ConditionAnalysis { | 401 enum ConditionAnalysis { |
| 403 ALWAYS_TRUE, | 402 ALWAYS_TRUE, |
| 404 ALWAYS_FALSE, | 403 ALWAYS_FALSE, |
| 405 DONT_KNOW | 404 DONT_KNOW |
| 406 }; | 405 }; |
| 407 ConditionAnalysis AnalyzeCondition(Expression* cond); | 406 ConditionAnalysis AnalyzeCondition(Expression* cond); |
| 408 | 407 |
| 409 // Methods used to indicate which source code is generated for. Source | 408 // Methods used to indicate which source code is generated for. Source |
| 410 // positions are collected by the assembler and emitted with the relocation | 409 // positions are collected by the assembler and emitted with the relocation |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 Major MajorKey() { return StringCompare; } | 616 Major MajorKey() { return StringCompare; } |
| 618 int MinorKey() { return 0; } | 617 int MinorKey() { return 0; } |
| 619 | 618 |
| 620 void Generate(MacroAssembler* masm); | 619 void Generate(MacroAssembler* masm); |
| 621 }; | 620 }; |
| 622 | 621 |
| 623 | 622 |
| 624 } } // namespace v8::internal | 623 } } // namespace v8::internal |
| 625 | 624 |
| 626 #endif // V8_ARM_CODEGEN_ARM_H_ | 625 #endif // V8_ARM_CODEGEN_ARM_H_ |
| OLD | NEW |