Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: src/x64/full-codegen-x64.cc

Issue 23618002: Hydrogenisation of binops (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(), op,
1927 op, 1924 expr->target(), expr->value());
1928 mode,
1929 expr->target(),
1930 expr->value());
1931 } else { 1925 } else {
1932 EmitBinaryOp(expr->binary_operation(), op, mode); 1926 EmitBinaryOp(expr->binary_operation(), op);
1933 } 1927 }
1934 // Deoptimization point in case the binary operation may have side effects. 1928 // Deoptimization point in case the binary operation may have side effects.
1935 PrepareForBailout(expr->binary_operation(), TOS_REG); 1929 PrepareForBailout(expr->binary_operation(), TOS_REG);
1936 } else { 1930 } else {
1937 VisitForAccumulatorValue(expr->value()); 1931 VisitForAccumulatorValue(expr->value());
1938 } 1932 }
1939 1933
1940 // Record source position before possible IC call. 1934 // Record source position before possible IC call.
1941 SetSourcePosition(expr->position()); 1935 SetSourcePosition(expr->position());
1942 1936
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 2244
2251 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { 2245 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
2252 SetSourcePosition(prop->position()); 2246 SetSourcePosition(prop->position());
2253 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); 2247 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
2254 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); 2248 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId());
2255 } 2249 }
2256 2250
2257 2251
2258 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, 2252 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
2259 Token::Value op, 2253 Token::Value op,
2260 OverwriteMode mode,
2261 Expression* left, 2254 Expression* left,
2262 Expression* right) { 2255 Expression* right) {
2263 // Do combined smi check of the operands. Left operand is on the 2256 // 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 2257 // stack (popped into rdx). Right operand is in rax but moved into
2265 // rcx to make the shifts easier. 2258 // rcx to make the shifts easier.
2266 Label done, stub_call, smi_case; 2259 Label done, stub_call, smi_case;
2267 __ pop(rdx); 2260 __ pop(rdx);
2268 __ movq(rcx, rax); 2261 __ movq(rcx, rax);
2269 __ or_(rax, rdx); 2262 __ or_(rax, rdx);
2270 JumpPatchSite patch_site(masm_); 2263 JumpPatchSite patch_site(masm_);
2271 patch_site.EmitJumpIfSmi(rax, &smi_case, Label::kNear); 2264 patch_site.EmitJumpIfSmi(rax, &smi_case, Label::kNear);
2272 2265
2273 __ bind(&stub_call); 2266 __ bind(&stub_call);
2274 __ movq(rax, rcx); 2267 __ movq(rax, rcx);
2275 BinaryOpStub stub(op, mode); 2268 BinaryOpStub stub(op);
2276 CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, 2269 CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET,
2277 expr->BinaryOperationFeedbackId()); 2270 expr->BinaryOperationFeedbackId());
2278 patch_site.EmitPatchInfo(); 2271 patch_site.EmitPatchInfo();
2279 __ jmp(&done, Label::kNear); 2272 __ jmp(&done, Label::kNear);
2280 2273
2281 __ bind(&smi_case); 2274 __ bind(&smi_case);
2282 switch (op) { 2275 switch (op) {
2283 case Token::SAR: 2276 case Token::SAR:
2284 __ SmiShiftArithmeticRight(rax, rdx, rcx); 2277 __ SmiShiftArithmeticRight(rax, rdx, rcx);
2285 break; 2278 break;
(...skipping 25 matching lines...) Expand all
2311 UNREACHABLE(); 2304 UNREACHABLE();
2312 break; 2305 break;
2313 } 2306 }
2314 2307
2315 __ bind(&done); 2308 __ bind(&done);
2316 context()->Plug(rax); 2309 context()->Plug(rax);
2317 } 2310 }
2318 2311
2319 2312
2320 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, 2313 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr,
2321 Token::Value op, 2314 Token::Value op) {
2322 OverwriteMode mode) {
2323 __ pop(rdx); 2315 __ pop(rdx);
2324 BinaryOpStub stub(op, mode); 2316 BinaryOpStub stub(op);
2325 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. 2317 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code.
2326 CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, 2318 CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET,
2327 expr->BinaryOperationFeedbackId()); 2319 expr->BinaryOperationFeedbackId());
2328 patch_site.EmitPatchInfo(); 2320 patch_site.EmitPatchInfo();
2329 context()->Plug(rax); 2321 context()->Plug(rax);
2330 } 2322 }
2331 2323
2332 2324
2333 void FullCodeGenerator::EmitAssignment(Expression* expr) { 2325 void FullCodeGenerator::EmitAssignment(Expression* expr) {
2334 // Invalid left-hand sides are rewritten by the parser to have a 'throw 2326 // 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
4444 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); 4436 __ SmiAddConstant(rax, rax, Smi::FromInt(1));
4445 } 4437 }
4446 } 4438 }
4447 4439
4448 // Record position before stub call. 4440 // Record position before stub call.
4449 SetSourcePosition(expr->position()); 4441 SetSourcePosition(expr->position());
4450 4442
4451 // Call stub for +1/-1. 4443 // Call stub for +1/-1.
4452 __ movq(rdx, rax); 4444 __ movq(rdx, rax);
4453 __ Move(rax, Smi::FromInt(1)); 4445 __ Move(rax, Smi::FromInt(1));
4454 BinaryOpStub stub(expr->binary_op(), NO_OVERWRITE); 4446 BinaryOpStub stub(expr->binary_op());
4455 CallIC(stub.GetCode(isolate()), 4447 CallIC(stub.GetCode(isolate()),
4456 RelocInfo::CODE_TARGET, 4448 RelocInfo::CODE_TARGET,
4457 expr->CountBinOpFeedbackId()); 4449 expr->CountBinOpFeedbackId());
4458 patch_site.EmitPatchInfo(); 4450 patch_site.EmitPatchInfo();
4459 __ bind(&done); 4451 __ bind(&done);
4460 4452
4461 // Store the value returned in rax. 4453 // Store the value returned in rax.
4462 switch (assign_type) { 4454 switch (assign_type) {
4463 case VARIABLE: 4455 case VARIABLE:
4464 if (expr->is_postfix()) { 4456 if (expr->is_postfix()) {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
4879 *context_length = 0; 4871 *context_length = 0;
4880 return previous_; 4872 return previous_;
4881 } 4873 }
4882 4874
4883 4875
4884 #undef __ 4876 #undef __
4885 4877
4886 } } // namespace v8::internal 4878 } } // namespace v8::internal
4887 4879
4888 #endif // V8_TARGET_ARCH_X64 4880 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698