OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 EmitKeyedPropertyLoad(property); | 1943 EmitKeyedPropertyLoad(property); |
1944 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1944 PrepareForBailoutForId(property->LoadId(), TOS_REG); |
1945 break; | 1945 break; |
1946 } | 1946 } |
1947 } | 1947 } |
1948 | 1948 |
1949 Token::Value op = expr->binary_op(); | 1949 Token::Value op = expr->binary_op(); |
1950 __ push(eax); // Left operand goes on the stack. | 1950 __ push(eax); // Left operand goes on the stack. |
1951 VisitForAccumulatorValue(expr->value()); | 1951 VisitForAccumulatorValue(expr->value()); |
1952 | 1952 |
1953 OverwriteMode mode = expr->value()->ResultOverwriteAllowed() | |
1954 ? OVERWRITE_RIGHT | |
1955 : NO_OVERWRITE; | |
1956 SetSourcePosition(expr->position() + 1); | 1953 SetSourcePosition(expr->position() + 1); |
1957 if (ShouldInlineSmiCase(op)) { | 1954 if (ShouldInlineSmiCase(op)) { |
1958 EmitInlineSmiBinaryOp(expr->binary_operation(), | 1955 EmitInlineSmiBinaryOp(expr->binary_operation(), |
1959 op, | 1956 op, |
1960 mode, | |
1961 expr->target(), | 1957 expr->target(), |
1962 expr->value()); | 1958 expr->value()); |
1963 } else { | 1959 } else { |
1964 EmitBinaryOp(expr->binary_operation(), op, mode); | 1960 EmitBinaryOp(expr->binary_operation(), op); |
1965 } | 1961 } |
1966 | 1962 |
1967 // Deoptimization point in case the binary operation may have side effects. | 1963 // Deoptimization point in case the binary operation may have side effects. |
1968 PrepareForBailout(expr->binary_operation(), TOS_REG); | 1964 PrepareForBailout(expr->binary_operation(), TOS_REG); |
1969 } else { | 1965 } else { |
1970 VisitForAccumulatorValue(expr->value()); | 1966 VisitForAccumulatorValue(expr->value()); |
1971 } | 1967 } |
1972 | 1968 |
1973 // Record source position before possible IC call. | 1969 // Record source position before possible IC call. |
1974 SetSourcePosition(expr->position()); | 1970 SetSourcePosition(expr->position()); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { | 2331 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { |
2336 // Stack: receiver, home_object, key. | 2332 // Stack: receiver, home_object, key. |
2337 SetSourcePosition(prop->position()); | 2333 SetSourcePosition(prop->position()); |
2338 | 2334 |
2339 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); | 2335 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
2340 } | 2336 } |
2341 | 2337 |
2342 | 2338 |
2343 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, | 2339 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, |
2344 Token::Value op, | 2340 Token::Value op, |
2345 OverwriteMode mode, | |
2346 Expression* left, | 2341 Expression* left, |
2347 Expression* right) { | 2342 Expression* right) { |
2348 // Do combined smi check of the operands. Left operand is on the | 2343 // Do combined smi check of the operands. Left operand is on the |
2349 // stack. Right operand is in eax. | 2344 // stack. Right operand is in eax. |
2350 Label smi_case, done, stub_call; | 2345 Label smi_case, done, stub_call; |
2351 __ pop(edx); | 2346 __ pop(edx); |
2352 __ mov(ecx, eax); | 2347 __ mov(ecx, eax); |
2353 __ or_(eax, edx); | 2348 __ or_(eax, edx); |
2354 JumpPatchSite patch_site(masm_); | 2349 JumpPatchSite patch_site(masm_); |
2355 patch_site.EmitJumpIfSmi(eax, &smi_case, Label::kNear); | 2350 patch_site.EmitJumpIfSmi(eax, &smi_case, Label::kNear); |
2356 | 2351 |
2357 __ bind(&stub_call); | 2352 __ bind(&stub_call); |
2358 __ mov(eax, ecx); | 2353 __ mov(eax, ecx); |
2359 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); | 2354 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code(); |
2360 CallIC(code, expr->BinaryOperationFeedbackId()); | 2355 CallIC(code, expr->BinaryOperationFeedbackId()); |
2361 patch_site.EmitPatchInfo(); | 2356 patch_site.EmitPatchInfo(); |
2362 __ jmp(&done, Label::kNear); | 2357 __ jmp(&done, Label::kNear); |
2363 | 2358 |
2364 // Smi case. | 2359 // Smi case. |
2365 __ bind(&smi_case); | 2360 __ bind(&smi_case); |
2366 __ mov(eax, edx); // Copy left operand in case of a stub call. | 2361 __ mov(eax, edx); // Copy left operand in case of a stub call. |
2367 | 2362 |
2368 switch (op) { | 2363 switch (op) { |
2369 case Token::SAR: | 2364 case Token::SAR: |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2481 } | 2476 } |
2482 | 2477 |
2483 // prototype | 2478 // prototype |
2484 __ CallRuntime(Runtime::kToFastProperties, 1); | 2479 __ CallRuntime(Runtime::kToFastProperties, 1); |
2485 | 2480 |
2486 // constructor | 2481 // constructor |
2487 __ CallRuntime(Runtime::kToFastProperties, 1); | 2482 __ CallRuntime(Runtime::kToFastProperties, 1); |
2488 } | 2483 } |
2489 | 2484 |
2490 | 2485 |
2491 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, | 2486 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { |
2492 Token::Value op, | |
2493 OverwriteMode mode) { | |
2494 __ pop(edx); | 2487 __ pop(edx); |
2495 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); | 2488 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code(); |
2496 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2489 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
2497 CallIC(code, expr->BinaryOperationFeedbackId()); | 2490 CallIC(code, expr->BinaryOperationFeedbackId()); |
2498 patch_site.EmitPatchInfo(); | 2491 patch_site.EmitPatchInfo(); |
2499 context()->Plug(eax); | 2492 context()->Plug(eax); |
2500 } | 2493 } |
2501 | 2494 |
2502 | 2495 |
2503 void FullCodeGenerator::EmitAssignment(Expression* expr) { | 2496 void FullCodeGenerator::EmitAssignment(Expression* expr) { |
2504 DCHECK(expr->IsValidReferenceExpression()); | 2497 DCHECK(expr->IsValidReferenceExpression()); |
2505 | 2498 |
(...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4756 } | 4749 } |
4757 } | 4750 } |
4758 | 4751 |
4759 // Record position before stub call. | 4752 // Record position before stub call. |
4760 SetSourcePosition(expr->position()); | 4753 SetSourcePosition(expr->position()); |
4761 | 4754 |
4762 // Call stub for +1/-1. | 4755 // Call stub for +1/-1. |
4763 __ bind(&stub_call); | 4756 __ bind(&stub_call); |
4764 __ mov(edx, eax); | 4757 __ mov(edx, eax); |
4765 __ mov(eax, Immediate(Smi::FromInt(1))); | 4758 __ mov(eax, Immediate(Smi::FromInt(1))); |
4766 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), expr->binary_op(), | 4759 Handle<Code> code = |
4767 NO_OVERWRITE).code(); | 4760 CodeFactory::BinaryOpIC(isolate(), expr->binary_op()).code(); |
4768 CallIC(code, expr->CountBinOpFeedbackId()); | 4761 CallIC(code, expr->CountBinOpFeedbackId()); |
4769 patch_site.EmitPatchInfo(); | 4762 patch_site.EmitPatchInfo(); |
4770 __ bind(&done); | 4763 __ bind(&done); |
4771 | 4764 |
4772 // Store the value returned in eax. | 4765 // Store the value returned in eax. |
4773 switch (assign_type) { | 4766 switch (assign_type) { |
4774 case VARIABLE: | 4767 case VARIABLE: |
4775 if (expr->is_postfix()) { | 4768 if (expr->is_postfix()) { |
4776 // Perform the assignment as if via '='. | 4769 // Perform the assignment as if via '='. |
4777 { EffectContext context(this); | 4770 { EffectContext context(this); |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5284 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5277 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5285 Assembler::target_address_at(call_target_address, | 5278 Assembler::target_address_at(call_target_address, |
5286 unoptimized_code)); | 5279 unoptimized_code)); |
5287 return OSR_AFTER_STACK_CHECK; | 5280 return OSR_AFTER_STACK_CHECK; |
5288 } | 5281 } |
5289 | 5282 |
5290 | 5283 |
5291 } } // namespace v8::internal | 5284 } } // namespace v8::internal |
5292 | 5285 |
5293 #endif // V8_TARGET_ARCH_X87 | 5286 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |