| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1910 EmitKeyedPropertyLoad(property); | 1910 EmitKeyedPropertyLoad(property); |
| 1911 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1911 PrepareForBailoutForId(property->LoadId(), TOS_REG); |
| 1912 break; | 1912 break; |
| 1913 } | 1913 } |
| 1914 } | 1914 } |
| 1915 | 1915 |
| 1916 Token::Value op = expr->binary_op(); | 1916 Token::Value op = expr->binary_op(); |
| 1917 __ push(rax); // Left operand goes on the stack. | 1917 __ push(rax); // Left operand goes on the stack. |
| 1918 VisitForAccumulatorValue(expr->value()); | 1918 VisitForAccumulatorValue(expr->value()); |
| 1919 | 1919 |
| 1920 OverwriteMode mode = expr->value()->ResultOverwriteAllowed() | |
| 1921 ? OVERWRITE_RIGHT | |
| 1922 : NO_OVERWRITE; | |
| 1923 SetSourcePosition(expr->position() + 1); | 1920 SetSourcePosition(expr->position() + 1); |
| 1924 AccumulatorValueContext context(this); | 1921 AccumulatorValueContext context(this); |
| 1925 if (ShouldInlineSmiCase(op)) { | 1922 if (ShouldInlineSmiCase(op)) { |
| 1926 EmitInlineSmiBinaryOp(expr->binary_operation(), | 1923 EmitInlineSmiBinaryOp(expr->binary_operation(), |
| 1927 op, | 1924 op, |
| 1928 mode, | |
| 1929 expr->target(), | 1925 expr->target(), |
| 1930 expr->value()); | 1926 expr->value()); |
| 1931 } else { | 1927 } else { |
| 1932 EmitBinaryOp(expr->binary_operation(), op, mode); | 1928 EmitBinaryOp(expr->binary_operation(), op); |
| 1933 } | 1929 } |
| 1934 // Deoptimization point in case the binary operation may have side effects. | 1930 // Deoptimization point in case the binary operation may have side effects. |
| 1935 PrepareForBailout(expr->binary_operation(), TOS_REG); | 1931 PrepareForBailout(expr->binary_operation(), TOS_REG); |
| 1936 } else { | 1932 } else { |
| 1937 VisitForAccumulatorValue(expr->value()); | 1933 VisitForAccumulatorValue(expr->value()); |
| 1938 } | 1934 } |
| 1939 | 1935 |
| 1940 // Record source position before possible IC call. | 1936 // Record source position before possible IC call. |
| 1941 SetSourcePosition(expr->position()); | 1937 SetSourcePosition(expr->position()); |
| 1942 | 1938 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2250 | 2246 |
| 2251 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2247 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
| 2252 SetSourcePosition(prop->position()); | 2248 SetSourcePosition(prop->position()); |
| 2253 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2249 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
| 2254 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); | 2250 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); |
| 2255 } | 2251 } |
| 2256 | 2252 |
| 2257 | 2253 |
| 2258 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, | 2254 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, |
| 2259 Token::Value op, | 2255 Token::Value op, |
| 2260 OverwriteMode mode, | |
| 2261 Expression* left, | 2256 Expression* left, |
| 2262 Expression* right) { | 2257 Expression* right) { |
| 2263 // Do combined smi check of the operands. Left operand is on the | 2258 // Do combined smi check of the operands. Left operand is on the |
| 2264 // stack (popped into rdx). Right operand is in rax but moved into | 2259 // stack (popped into rdx). Right operand is in rax but moved into |
| 2265 // rcx to make the shifts easier. | 2260 // rcx to make the shifts easier. |
| 2266 Label done, stub_call, smi_case; | 2261 Label done, stub_call, smi_case; |
| 2267 __ pop(rdx); | 2262 __ pop(rdx); |
| 2268 __ movq(rcx, rax); | 2263 __ movq(rcx, rax); |
| 2269 __ or_(rax, rdx); | 2264 __ or_(rax, rdx); |
| 2270 JumpPatchSite patch_site(masm_); | 2265 JumpPatchSite patch_site(masm_); |
| 2271 patch_site.EmitJumpIfSmi(rax, &smi_case, Label::kNear); | 2266 patch_site.EmitJumpIfSmi(rax, &smi_case, Label::kNear); |
| 2272 | 2267 |
| 2273 __ bind(&stub_call); | 2268 __ bind(&stub_call); |
| 2274 __ movq(rax, rcx); | 2269 __ movq(rax, rcx); |
| 2275 BinaryOpStub stub(op, mode); | 2270 BinaryOpStub stub(op); |
| 2276 CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, | 2271 CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, |
| 2277 expr->BinaryOperationFeedbackId()); | 2272 expr->BinaryOperationFeedbackId()); |
| 2278 patch_site.EmitPatchInfo(); | 2273 patch_site.EmitPatchInfo(); |
| 2279 __ jmp(&done, Label::kNear); | 2274 __ jmp(&done, Label::kNear); |
| 2280 | 2275 |
| 2281 __ bind(&smi_case); | 2276 __ bind(&smi_case); |
| 2282 switch (op) { | 2277 switch (op) { |
| 2283 case Token::SAR: | 2278 case Token::SAR: |
| 2284 __ SmiShiftArithmeticRight(rax, rdx, rcx); | 2279 __ SmiShiftArithmeticRight(rax, rdx, rcx); |
| 2285 break; | 2280 break; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2311 UNREACHABLE(); | 2306 UNREACHABLE(); |
| 2312 break; | 2307 break; |
| 2313 } | 2308 } |
| 2314 | 2309 |
| 2315 __ bind(&done); | 2310 __ bind(&done); |
| 2316 context()->Plug(rax); | 2311 context()->Plug(rax); |
| 2317 } | 2312 } |
| 2318 | 2313 |
| 2319 | 2314 |
| 2320 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, | 2315 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, |
| 2321 Token::Value op, | 2316 Token::Value op) { |
| 2322 OverwriteMode mode) { | |
| 2323 __ pop(rdx); | 2317 __ pop(rdx); |
| 2324 BinaryOpStub stub(op, mode); | 2318 BinaryOpStub stub(op); |
| 2325 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2319 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
| 2326 CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, | 2320 CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, |
| 2327 expr->BinaryOperationFeedbackId()); | 2321 expr->BinaryOperationFeedbackId()); |
| 2328 patch_site.EmitPatchInfo(); | 2322 patch_site.EmitPatchInfo(); |
| 2329 context()->Plug(rax); | 2323 context()->Plug(rax); |
| 2330 } | 2324 } |
| 2331 | 2325 |
| 2332 | 2326 |
| 2333 void FullCodeGenerator::EmitAssignment(Expression* expr) { | 2327 void FullCodeGenerator::EmitAssignment(Expression* expr) { |
| 2334 // Invalid left-hand sides are rewritten by the parser to have a 'throw | 2328 // Invalid left-hand sides are rewritten by the parser to have a 'throw |
| (...skipping 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4444 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); | 4438 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); |
| 4445 } | 4439 } |
| 4446 } | 4440 } |
| 4447 | 4441 |
| 4448 // Record position before stub call. | 4442 // Record position before stub call. |
| 4449 SetSourcePosition(expr->position()); | 4443 SetSourcePosition(expr->position()); |
| 4450 | 4444 |
| 4451 // Call stub for +1/-1. | 4445 // Call stub for +1/-1. |
| 4452 __ movq(rdx, rax); | 4446 __ movq(rdx, rax); |
| 4453 __ Move(rax, Smi::FromInt(1)); | 4447 __ Move(rax, Smi::FromInt(1)); |
| 4454 BinaryOpStub stub(expr->binary_op(), NO_OVERWRITE); | 4448 BinaryOpStub stub(expr->binary_op()); |
| 4455 CallIC(stub.GetCode(isolate()), | 4449 CallIC(stub.GetCode(isolate()), |
| 4456 RelocInfo::CODE_TARGET, | 4450 RelocInfo::CODE_TARGET, |
| 4457 expr->CountBinOpFeedbackId()); | 4451 expr->CountBinOpFeedbackId()); |
| 4458 patch_site.EmitPatchInfo(); | 4452 patch_site.EmitPatchInfo(); |
| 4459 __ bind(&done); | 4453 __ bind(&done); |
| 4460 | 4454 |
| 4461 // Store the value returned in rax. | 4455 // Store the value returned in rax. |
| 4462 switch (assign_type) { | 4456 switch (assign_type) { |
| 4463 case VARIABLE: | 4457 case VARIABLE: |
| 4464 if (expr->is_postfix()) { | 4458 if (expr->is_postfix()) { |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4879 *context_length = 0; | 4873 *context_length = 0; |
| 4880 return previous_; | 4874 return previous_; |
| 4881 } | 4875 } |
| 4882 | 4876 |
| 4883 | 4877 |
| 4884 #undef __ | 4878 #undef __ |
| 4885 | 4879 |
| 4886 } } // namespace v8::internal | 4880 } } // namespace v8::internal |
| 4887 | 4881 |
| 4888 #endif // V8_TARGET_ARCH_X64 | 4882 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |