| OLD | NEW | 
|     1 // Copyright 2010 the V8 project authors. All rights reserved. |     1 // Copyright 2010 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 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1189     // call. It is treated specially by the LoadIC code. |  1189     // call. It is treated specially by the LoadIC code. | 
|  1190     __ nop(); |  1190     __ nop(); | 
|  1191     // Drop key and object left on the stack by IC. |  1191     // Drop key and object left on the stack by IC. | 
|  1192     Apply(context, eax); |  1192     Apply(context, eax); | 
|  1193   } |  1193   } | 
|  1194 } |  1194 } | 
|  1195  |  1195  | 
|  1196  |  1196  | 
|  1197 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |  1197 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { | 
|  1198   Comment cmnt(masm_, "[ RegExpLiteral"); |  1198   Comment cmnt(masm_, "[ RegExpLiteral"); | 
|  1199   Label done; |  1199   Label materialized; | 
|  1200   // Registers will be used as follows: |  1200   // Registers will be used as follows: | 
|  1201   // edi = JS function. |  1201   // edi = JS function. | 
|  1202   // ebx = literals array. |  1202   // ecx = literals array. | 
|  1203   // eax = regexp literal. |  1203   // ebx = regexp literal. | 
 |  1204   // eax = regexp literal clone. | 
|  1204   __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |  1205   __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 
|  1205   __ mov(ebx, FieldOperand(edi, JSFunction::kLiteralsOffset)); |  1206   __ mov(ecx, FieldOperand(edi, JSFunction::kLiteralsOffset)); | 
|  1206   int literal_offset = |  1207   int literal_offset = | 
|  1207     FixedArray::kHeaderSize + expr->literal_index() * kPointerSize; |  1208     FixedArray::kHeaderSize + expr->literal_index() * kPointerSize; | 
|  1208   __ mov(eax, FieldOperand(ebx, literal_offset)); |  1209   __ mov(ebx, FieldOperand(ecx, literal_offset)); | 
|  1209   __ cmp(eax, Factory::undefined_value()); |  1210   __ cmp(ebx, Factory::undefined_value()); | 
|  1210   __ j(not_equal, &done); |  1211   __ j(not_equal, &materialized); | 
 |  1212  | 
|  1211   // Create regexp literal using runtime function |  1213   // Create regexp literal using runtime function | 
|  1212   // Result will be in eax. |  1214   // Result will be in eax. | 
|  1213   __ push(ebx); |  1215   __ push(ecx); | 
|  1214   __ push(Immediate(Smi::FromInt(expr->literal_index()))); |  1216   __ push(Immediate(Smi::FromInt(expr->literal_index()))); | 
|  1215   __ push(Immediate(expr->pattern())); |  1217   __ push(Immediate(expr->pattern())); | 
|  1216   __ push(Immediate(expr->flags())); |  1218   __ push(Immediate(expr->flags())); | 
|  1217   __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4); |  1219   __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4); | 
|  1218   // Label done: |  1220   __ mov(ebx, eax); | 
|  1219   __ bind(&done); |  1221  | 
 |  1222   __ bind(&materialized); | 
 |  1223   int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize; | 
 |  1224   Label allocated, runtime_allocate; | 
 |  1225   __ AllocateInNewSpace(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT); | 
 |  1226   __ jmp(&allocated); | 
 |  1227  | 
 |  1228   __ bind(&runtime_allocate); | 
 |  1229   __ push(ebx); | 
 |  1230   __ push(Immediate(Smi::FromInt(size))); | 
 |  1231   __ CallRuntime(Runtime::kAllocateInNewSpace, 1); | 
 |  1232   __ pop(ebx); | 
 |  1233  | 
 |  1234   __ bind(&allocated); | 
 |  1235   // Copy the content into the newly allocated memory. | 
 |  1236   // (Unroll copy loop once for better throughput). | 
 |  1237   for (int i = 0; i < size - kPointerSize; i += 2 * kPointerSize) { | 
 |  1238     __ mov(edx, FieldOperand(ebx, i)); | 
 |  1239     __ mov(ecx, FieldOperand(ebx, i + kPointerSize)); | 
 |  1240     __ mov(FieldOperand(eax, i), edx); | 
 |  1241     __ mov(FieldOperand(eax, i + kPointerSize), ecx); | 
 |  1242   } | 
 |  1243   if ((size % (2 * kPointerSize)) != 0) { | 
 |  1244     __ mov(edx, FieldOperand(ebx, size - kPointerSize)); | 
 |  1245     __ mov(FieldOperand(eax, size - kPointerSize), edx); | 
 |  1246   } | 
|  1220   Apply(context_, eax); |  1247   Apply(context_, eax); | 
|  1221 } |  1248 } | 
|  1222  |  1249  | 
|  1223  |  1250  | 
|  1224 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |  1251 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 
|  1225   Comment cmnt(masm_, "[ ObjectLiteral"); |  1252   Comment cmnt(masm_, "[ ObjectLiteral"); | 
|  1226   __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |  1253   __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 
|  1227   __ push(FieldOperand(edi, JSFunction::kLiteralsOffset)); |  1254   __ push(FieldOperand(edi, JSFunction::kLiteralsOffset)); | 
|  1228   __ push(Immediate(Smi::FromInt(expr->literal_index()))); |  1255   __ push(Immediate(Smi::FromInt(expr->literal_index()))); | 
|  1229   __ push(Immediate(expr->constant_properties())); |  1256   __ push(Immediate(expr->constant_properties())); | 
| (...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2643   // Call runtime to perform the lookup. |  2670   // Call runtime to perform the lookup. | 
|  2644   __ push(cache); |  2671   __ push(cache); | 
|  2645   __ push(key); |  2672   __ push(key); | 
|  2646   __ CallRuntime(Runtime::kGetFromCache, 2); |  2673   __ CallRuntime(Runtime::kGetFromCache, 2); | 
|  2647  |  2674  | 
|  2648   __ bind(&done); |  2675   __ bind(&done); | 
|  2649   Apply(context_, eax); |  2676   Apply(context_, eax); | 
|  2650 } |  2677 } | 
|  2651  |  2678  | 
|  2652  |  2679  | 
 |  2680 void FullCodeGenerator::EmitIsRegExpEquivalent(ZoneList<Expression*>* args) { | 
 |  2681   ASSERT_EQ(2, args->length()); | 
 |  2682  | 
 |  2683   Register right = eax; | 
 |  2684   Register left = ebx; | 
 |  2685   Register tmp = ecx; | 
 |  2686  | 
 |  2687   VisitForValue(args->at(0), kStack); | 
 |  2688   VisitForValue(args->at(1), kAccumulator); | 
 |  2689   __ pop(left); | 
 |  2690  | 
 |  2691   Label done, fail, ok; | 
 |  2692   __ cmp(left, Operand(right)); | 
 |  2693   __ j(equal, &ok); | 
 |  2694   // Fail if either is a non-HeapObject. | 
 |  2695   __ mov(tmp, left); | 
 |  2696   __ and_(Operand(tmp), right); | 
 |  2697   __ test(Operand(tmp), Immediate(kSmiTagMask)); | 
 |  2698   __ j(zero, &fail); | 
 |  2699   __ mov(tmp, FieldOperand(left, HeapObject::kMapOffset)); | 
 |  2700   __ cmpb(FieldOperand(tmp, Map::kInstanceTypeOffset), | 
 |  2701           static_cast<int8_t>(JS_REGEXP_TYPE)); | 
 |  2702   __ j(not_equal, &fail); | 
 |  2703   __ cmp(tmp, FieldOperand(right, HeapObject::kMapOffset)); | 
 |  2704   __ j(not_equal, &fail); | 
 |  2705   __ mov(tmp, FieldOperand(left, JSRegExp::kDataOffset)); | 
 |  2706   __ cmp(tmp, FieldOperand(right, JSRegExp::kDataOffset)); | 
 |  2707   __ j(equal, &ok); | 
 |  2708   __ bind(&fail); | 
 |  2709   __ mov(eax, Immediate(Factory::false_value())); | 
 |  2710   __ jmp(&done); | 
 |  2711   __ bind(&ok); | 
 |  2712   __ mov(eax, Immediate(Factory::true_value())); | 
 |  2713   __ bind(&done); | 
 |  2714  | 
 |  2715   Apply(context_, eax); | 
 |  2716 } | 
 |  2717  | 
 |  2718  | 
|  2653 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |  2719 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 
|  2654   Handle<String> name = expr->name(); |  2720   Handle<String> name = expr->name(); | 
|  2655   if (name->length() > 0 && name->Get(0) == '_') { |  2721   if (name->length() > 0 && name->Get(0) == '_') { | 
|  2656     Comment cmnt(masm_, "[ InlineRuntimeCall"); |  2722     Comment cmnt(masm_, "[ InlineRuntimeCall"); | 
|  2657     EmitInlineRuntimeCall(expr); |  2723     EmitInlineRuntimeCall(expr); | 
|  2658     return; |  2724     return; | 
|  2659   } |  2725   } | 
|  2660  |  2726  | 
|  2661   Comment cmnt(masm_, "[ CallRuntime"); |  2727   Comment cmnt(masm_, "[ CallRuntime"); | 
|  2662   ZoneList<Expression*>* args = expr->arguments(); |  2728   ZoneList<Expression*>* args = expr->arguments(); | 
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3272   // And return. |  3338   // And return. | 
|  3273   __ ret(0); |  3339   __ ret(0); | 
|  3274 } |  3340 } | 
|  3275  |  3341  | 
|  3276  |  3342  | 
|  3277 #undef __ |  3343 #undef __ | 
|  3278  |  3344  | 
|  3279 } }  // namespace v8::internal |  3345 } }  // namespace v8::internal | 
|  3280  |  3346  | 
|  3281 #endif  // V8_TARGET_ARCH_IA32 |  3347 #endif  // V8_TARGET_ARCH_IA32 | 
| OLD | NEW |