| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 CompilationInfo* info_; | 59 CompilationInfo* info_; |
| 60 bool has_supported_syntax_; | 60 bool has_supported_syntax_; |
| 61 | 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(FastCodeGenSyntaxChecker); | 62 DISALLOW_COPY_AND_ASSIGN(FastCodeGenSyntaxChecker); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 | 65 |
| 66 class FastCodeGenerator: public AstVisitor { | 66 class FastCodeGenerator: public AstVisitor { |
| 67 public: | 67 public: |
| 68 FastCodeGenerator(Handle<Script> script, bool is_eval) | 68 FastCodeGenerator(MacroAssembler* masm, Handle<Script> script, bool is_eval) |
| 69 : masm_(NULL), | 69 : masm_(masm), |
| 70 script_(script), | 70 script_(script), |
| 71 is_eval_(is_eval), | 71 is_eval_(is_eval), |
| 72 function_(NULL), | 72 function_(NULL), |
| 73 info_(NULL) { | 73 info_(NULL) { |
| 74 } | 74 } |
| 75 | 75 |
| 76 static void MakeCode(FunctionLiteral* fun, | 76 static Handle<Code> MakeCode(FunctionLiteral* fun, |
| 77 Handle<Script> script, | 77 Handle<Script> script, |
| 78 bool is_eval, | 78 bool is_eval, |
| 79 CompilationInfo* info); | 79 CompilationInfo* info); |
| 80 | 80 |
| 81 void Generate(FunctionLiteral* fun, CompilationInfo* info); | 81 void Generate(FunctionLiteral* fun, CompilationInfo* info); |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 MacroAssembler* masm() { return masm_; } |
| 85 FunctionLiteral* function() { return function_; } |
| 86 Label* bailout() { return &bailout_; } |
| 87 |
| 88 bool has_receiver() { return !info_->receiver().is_null(); } |
| 89 Handle<Object> receiver() { return info_->receiver(); } |
| 90 bool has_this_properties() { return info_->has_this_properties(); } |
| 91 |
| 84 // AST node visit functions. | 92 // AST node visit functions. |
| 85 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 93 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 86 AST_NODE_LIST(DECLARE_VISIT) | 94 AST_NODE_LIST(DECLARE_VISIT) |
| 87 #undef DECLARE_VISIT | 95 #undef DECLARE_VISIT |
| 88 | 96 |
| 97 // Emit code to load the receiver from the stack into a given register. |
| 98 void EmitLoadReceiver(Register reg); |
| 99 |
| 100 // Emit code to check that the receiver has the same map as the |
| 101 // compile-time receiver. Receiver is expected in {ia32-edx, x64-rdx, |
| 102 // arm-r1}. Emit a branch to the (single) bailout label if check fails. |
| 103 void EmitReceiverMapCheck(); |
| 104 |
| 105 // Emit code to load a global variable value into {is32-eax, x64-rax, |
| 106 // arm-r0}. Register {ia32-edx, x64-rdx, arm-r1} is preserved if it is |
| 107 // holding the receiver and {is32-ecx, x64-rcx, arm-r2} is always |
| 108 // clobbered. |
| 109 void EmitGlobalVariableLoad(Handle<String> name); |
| 110 |
| 111 // Emit a store to an own property of this. The stored value is expected |
| 112 // in {ia32-eax, x64-rax, arm-r0} and the receiver in {is32-edx, x64-rdx, |
| 113 // arm-r1}. Both are preserve. |
| 114 void EmitThisPropertyStore(Handle<String> name); |
| 115 |
| 89 MacroAssembler* masm_; | 116 MacroAssembler* masm_; |
| 90 Handle<Script> script_; | 117 Handle<Script> script_; |
| 91 bool is_eval_; | 118 bool is_eval_; |
| 92 | 119 |
| 93 FunctionLiteral* function_; | 120 FunctionLiteral* function_; |
| 94 CompilationInfo* info_; | 121 CompilationInfo* info_; |
| 95 | 122 |
| 123 Label bailout_; |
| 124 |
| 96 DISALLOW_COPY_AND_ASSIGN(FastCodeGenerator); | 125 DISALLOW_COPY_AND_ASSIGN(FastCodeGenerator); |
| 97 }; | 126 }; |
| 98 | 127 |
| 99 | 128 |
| 100 } } // namespace v8::internal | 129 } } // namespace v8::internal |
| 101 | 130 |
| 102 #endif // V8_FAST_CODEGEN_H_ | 131 #endif // V8_FAST_CODEGEN_H_ |
| OLD | NEW |