| OLD | NEW | 
|     1 // Copyright 2009 the V8 project authors. All rights reserved. |     1 // Copyright 2009 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   373   // r0 contains boilerplate. |   373   // r0 contains boilerplate. | 
|   374   // Clone boilerplate. |   374   // Clone boilerplate. | 
|   375   __ push(r0); |   375   __ push(r0); | 
|   376   if (expr->depth() > 1) { |   376   if (expr->depth() > 1) { | 
|   377     __ CallRuntime(Runtime::kCloneLiteralBoilerplate, 1); |   377     __ CallRuntime(Runtime::kCloneLiteralBoilerplate, 1); | 
|   378   } else { |   378   } else { | 
|   379     __ CallRuntime(Runtime::kCloneShallowLiteralBoilerplate, 1); |   379     __ CallRuntime(Runtime::kCloneShallowLiteralBoilerplate, 1); | 
|   380   } |   380   } | 
|   381  |   381  | 
|   382   // If result_saved == true: the result is saved on top of the stack. |   382   // If result_saved == true: the result is saved on top of the stack. | 
|   383   // If result_saved == false: the result is in eax. |   383   // If result_saved == false: the result is in r0. | 
|   384   bool result_saved = false; |   384   bool result_saved = false; | 
|   385  |   385  | 
|   386   for (int i = 0; i < expr->properties()->length(); i++) { |   386   for (int i = 0; i < expr->properties()->length(); i++) { | 
|   387     ObjectLiteral::Property* property = expr->properties()->at(i); |   387     ObjectLiteral::Property* property = expr->properties()->at(i); | 
|   388     if (property->IsCompileTimeValue()) continue; |   388     if (property->IsCompileTimeValue()) continue; | 
|   389  |   389  | 
|   390     Literal* key = property->key(); |   390     Literal* key = property->key(); | 
|   391     Expression* value = property->value(); |   391     Expression* value = property->value(); | 
|   392     if (!result_saved) { |   392     if (!result_saved) { | 
|   393       __ push(r0);  // Save result on stack |   393       __ push(r0);  // Save result on stack | 
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   900           break; |   900           break; | 
|   901       } |   901       } | 
|   902       break; |   902       break; | 
|   903  |   903  | 
|   904     default: |   904     default: | 
|   905       UNREACHABLE(); |   905       UNREACHABLE(); | 
|   906   } |   906   } | 
|   907 } |   907 } | 
|   908  |   908  | 
|   909  |   909  | 
 |   910 void FastCodeGenerator::VisitCountOperation(CountOperation* expr) { | 
 |   911   VariableProxy* v = expr->expression()->AsVariableProxy(); | 
 |   912   ASSERT(v->AsVariable() != NULL); | 
 |   913   ASSERT(v->AsVariable()->is_global()); | 
 |   914  | 
 |   915   Visit(v); | 
 |   916  | 
 |   917   __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_JS); | 
 |   918  | 
 |   919   switch (expr->context()) { | 
 |   920     case Expression::kUninitialized: | 
 |   921       UNREACHABLE(); | 
 |   922     case Expression::kValue:  // Fall through | 
 |   923     case Expression::kTest:  // Fall through | 
 |   924     case Expression::kTestValue:  // Fall through | 
 |   925     case Expression::kValueTest: | 
 |   926       // Duplicate the result on the stack. | 
 |   927       __ push(r0); | 
 |   928       break; | 
 |   929     case Expression::kEffect: | 
 |   930       // Do not save result. | 
 |   931       break; | 
 |   932   } | 
 |   933   // Call runtime for +1/-1. | 
 |   934   __ push(r0); | 
 |   935   __ mov(ip, Operand(Smi::FromInt(1))); | 
 |   936   __ push(ip); | 
 |   937   if (expr->op() == Token::INC) { | 
 |   938     __ CallRuntime(Runtime::kNumberAdd, 2); | 
 |   939   } else { | 
 |   940     __ CallRuntime(Runtime::kNumberSub, 2); | 
 |   941   } | 
 |   942   // Call Store IC. | 
 |   943   __ mov(r2, Operand(v->AsVariable()->name())); | 
 |   944   __ ldr(ip, CodeGenerator::GlobalObject()); | 
 |   945   __ push(ip); | 
 |   946   Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 
 |   947   __ Call(ic, RelocInfo::CODE_TARGET); | 
 |   948   // Restore up stack after store IC. | 
 |   949   __ add(sp, sp, Operand(kPointerSize)); | 
 |   950  | 
 |   951   switch (expr->context()) { | 
 |   952     case Expression::kUninitialized: | 
 |   953       UNREACHABLE(); | 
 |   954     case Expression::kEffect:  // Fall through | 
 |   955     case Expression::kValue: | 
 |   956       // Do nothing. Result in either on the stack for value context | 
 |   957       // or discarded for effect context. | 
 |   958       break; | 
 |   959     case Expression::kTest: | 
 |   960       __ pop(r0); | 
 |   961       TestAndBranch(r0, true_label_, false_label_); | 
 |   962       break; | 
 |   963     case Expression::kValueTest: { | 
 |   964       Label discard; | 
 |   965       __ ldr(r0, MemOperand(sp)); | 
 |   966       TestAndBranch(r0, true_label_, &discard); | 
 |   967       __ bind(&discard); | 
 |   968       __ add(sp, sp, Operand(kPointerSize)); | 
 |   969       __ b(false_label_); | 
 |   970       break; | 
 |   971     } | 
 |   972     case Expression::kTestValue: { | 
 |   973       Label discard; | 
 |   974       __ ldr(r0, MemOperand(sp)); | 
 |   975       TestAndBranch(r0, &discard, false_label_); | 
 |   976       __ bind(&discard); | 
 |   977       __ add(sp, sp, Operand(kPointerSize)); | 
 |   978       __ b(true_label_); | 
 |   979       break; | 
 |   980     } | 
 |   981   } | 
 |   982 } | 
 |   983  | 
 |   984  | 
|   910 void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { |   985 void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { | 
|   911   switch (expr->op()) { |   986   switch (expr->op()) { | 
|   912     case Token::COMMA: |   987     case Token::COMMA: | 
|   913       ASSERT_EQ(Expression::kEffect, expr->left()->context()); |   988       ASSERT_EQ(Expression::kEffect, expr->left()->context()); | 
|   914       ASSERT_EQ(expr->context(), expr->right()->context()); |   989       ASSERT_EQ(expr->context(), expr->right()->context()); | 
|   915       Visit(expr->left()); |   990       Visit(expr->left()); | 
|   916       Visit(expr->right()); |   991       Visit(expr->right()); | 
|   917       break; |   992       break; | 
|   918  |   993  | 
|   919     case Token::OR: |   994     case Token::OR: | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
|   946  |  1021  | 
|   947       break; |  1022       break; | 
|   948     } |  1023     } | 
|   949     default: |  1024     default: | 
|   950       UNREACHABLE(); |  1025       UNREACHABLE(); | 
|   951   } |  1026   } | 
|   952 } |  1027 } | 
|   953  |  1028  | 
|   954  |  1029  | 
|   955 } }  // namespace v8::internal |  1030 } }  // namespace v8::internal | 
| OLD | NEW |