OLD | NEW |
(Empty) | |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 #include "v8.h" |
| 29 |
| 30 #include "codegen-inl.h" |
| 31 #include "fast-codegen.h" |
| 32 |
| 33 namespace v8 { |
| 34 namespace internal { |
| 35 |
| 36 Handle<Code> FastCodeGenerator::MakeCode(FunctionLiteral* fun, |
| 37 Handle<Script> script) { |
| 38 CodeGenerator::MakeCodePrologue(fun); |
| 39 const int kInitialBufferSize = 4 * KB; |
| 40 MacroAssembler masm(NULL, kInitialBufferSize); |
| 41 FastCodeGenerator cgen(&masm); |
| 42 cgen.Generate(fun); |
| 43 if (cgen.HasStackOverflow()) { |
| 44 ASSERT(!Top::has_pending_exception()); |
| 45 return Handle<Code>::null(); |
| 46 } |
| 47 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, NOT_IN_LOOP); |
| 48 return CodeGenerator::MakeCodeEpilogue(fun, &masm, flags, script); |
| 49 } |
| 50 |
| 51 |
| 52 int FastCodeGenerator::SlotOffset(Slot* slot) { |
| 53 // Offset is negative because higher indexes are at lower addresses. |
| 54 int offset = -slot->index() * kPointerSize; |
| 55 // Adjust by a (parameter or local) base offset. |
| 56 switch (slot->type()) { |
| 57 case Slot::PARAMETER: |
| 58 offset += (function_->scope()->num_parameters() + 1) * kPointerSize; |
| 59 break; |
| 60 case Slot::LOCAL: |
| 61 offset += JavaScriptFrameConstants::kLocal0Offset; |
| 62 break; |
| 63 default: |
| 64 UNREACHABLE(); |
| 65 } |
| 66 return offset; |
| 67 } |
| 68 |
| 69 |
| 70 void FastCodeGenerator::VisitDeclaration(Declaration* decl) { |
| 71 UNREACHABLE(); |
| 72 } |
| 73 |
| 74 |
| 75 void FastCodeGenerator::VisitBlock(Block* stmt) { |
| 76 UNREACHABLE(); |
| 77 } |
| 78 |
| 79 |
| 80 void FastCodeGenerator::VisitEmptyStatement(EmptyStatement* stmt) { |
| 81 UNREACHABLE(); |
| 82 } |
| 83 |
| 84 |
| 85 void FastCodeGenerator::VisitIfStatement(IfStatement* stmt) { |
| 86 UNREACHABLE(); |
| 87 } |
| 88 |
| 89 |
| 90 void FastCodeGenerator::VisitContinueStatement(ContinueStatement* stmt) { |
| 91 UNREACHABLE(); |
| 92 } |
| 93 |
| 94 |
| 95 void FastCodeGenerator::VisitBreakStatement(BreakStatement* stmt) { |
| 96 UNREACHABLE(); |
| 97 } |
| 98 |
| 99 |
| 100 void FastCodeGenerator::VisitWithEnterStatement(WithEnterStatement* stmt) { |
| 101 UNREACHABLE(); |
| 102 } |
| 103 |
| 104 |
| 105 void FastCodeGenerator::VisitWithExitStatement(WithExitStatement* stmt) { |
| 106 UNREACHABLE(); |
| 107 } |
| 108 |
| 109 |
| 110 void FastCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
| 111 UNREACHABLE(); |
| 112 } |
| 113 |
| 114 |
| 115 void FastCodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) { |
| 116 UNREACHABLE(); |
| 117 } |
| 118 |
| 119 |
| 120 void FastCodeGenerator::VisitWhileStatement(WhileStatement* stmt) { |
| 121 UNREACHABLE(); |
| 122 } |
| 123 |
| 124 |
| 125 void FastCodeGenerator::VisitForStatement(ForStatement* stmt) { |
| 126 UNREACHABLE(); |
| 127 } |
| 128 |
| 129 |
| 130 void FastCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
| 131 UNREACHABLE(); |
| 132 } |
| 133 |
| 134 |
| 135 void FastCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { |
| 136 UNREACHABLE(); |
| 137 } |
| 138 |
| 139 |
| 140 void FastCodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) { |
| 141 UNREACHABLE(); |
| 142 } |
| 143 |
| 144 |
| 145 void FastCodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) { |
| 146 UNREACHABLE(); |
| 147 } |
| 148 |
| 149 |
| 150 void FastCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { |
| 151 UNREACHABLE(); |
| 152 } |
| 153 |
| 154 |
| 155 void FastCodeGenerator::VisitFunctionBoilerplateLiteral( |
| 156 FunctionBoilerplateLiteral* expr) { |
| 157 UNREACHABLE(); |
| 158 } |
| 159 |
| 160 |
| 161 void FastCodeGenerator::VisitConditional(Conditional* expr) { |
| 162 UNREACHABLE(); |
| 163 } |
| 164 |
| 165 |
| 166 void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 167 UNREACHABLE(); |
| 168 } |
| 169 |
| 170 |
| 171 void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
| 172 UNREACHABLE(); |
| 173 } |
| 174 |
| 175 |
| 176 void FastCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
| 177 UNREACHABLE(); |
| 178 } |
| 179 |
| 180 |
| 181 void FastCodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* expr) { |
| 182 UNREACHABLE(); |
| 183 } |
| 184 |
| 185 |
| 186 void FastCodeGenerator::VisitThrow(Throw* expr) { |
| 187 UNREACHABLE(); |
| 188 } |
| 189 |
| 190 |
| 191 void FastCodeGenerator::VisitProperty(Property* expr) { |
| 192 UNREACHABLE(); |
| 193 } |
| 194 |
| 195 |
| 196 void FastCodeGenerator::VisitCall(Call* expr) { |
| 197 UNREACHABLE(); |
| 198 } |
| 199 |
| 200 |
| 201 void FastCodeGenerator::VisitCallNew(CallNew* expr) { |
| 202 UNREACHABLE(); |
| 203 } |
| 204 |
| 205 |
| 206 void FastCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
| 207 UNREACHABLE(); |
| 208 } |
| 209 |
| 210 |
| 211 void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { |
| 212 UNREACHABLE(); |
| 213 } |
| 214 |
| 215 |
| 216 void FastCodeGenerator::VisitCountOperation(CountOperation* expr) { |
| 217 UNREACHABLE(); |
| 218 } |
| 219 |
| 220 |
| 221 void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { |
| 222 UNREACHABLE(); |
| 223 } |
| 224 |
| 225 |
| 226 void FastCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
| 227 UNREACHABLE(); |
| 228 } |
| 229 |
| 230 |
| 231 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { |
| 232 UNREACHABLE(); |
| 233 } |
| 234 |
| 235 |
| 236 } } // namespace v8::internal |
OLD | NEW |