| 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 3287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3298 ZoneList<Expression*>* args = expr->arguments(); | 3298 ZoneList<Expression*>* args = expr->arguments(); |
| 3299 ASSERT(args->length() == 3); | 3299 ASSERT(args->length() == 3); |
| 3300 VisitForStackValue(args->at(0)); | 3300 VisitForStackValue(args->at(0)); |
| 3301 VisitForStackValue(args->at(1)); | 3301 VisitForStackValue(args->at(1)); |
| 3302 VisitForStackValue(args->at(2)); | 3302 VisitForStackValue(args->at(2)); |
| 3303 __ CallStub(&stub); | 3303 __ CallStub(&stub); |
| 3304 context()->Plug(eax); | 3304 context()->Plug(eax); |
| 3305 } | 3305 } |
| 3306 | 3306 |
| 3307 | 3307 |
| 3308 void FullCodeGenerator::EmitSwapElements(CallRuntime* expr) { | |
| 3309 ZoneList<Expression*>* args = expr->arguments(); | |
| 3310 ASSERT(args->length() == 3); | |
| 3311 VisitForStackValue(args->at(0)); | |
| 3312 VisitForStackValue(args->at(1)); | |
| 3313 VisitForStackValue(args->at(2)); | |
| 3314 Label done; | |
| 3315 Label slow_case; | |
| 3316 Register object = eax; | |
| 3317 Register index_1 = ebx; | |
| 3318 Register index_2 = ecx; | |
| 3319 Register elements = edi; | |
| 3320 Register temp = edx; | |
| 3321 __ mov(object, Operand(esp, 2 * kPointerSize)); | |
| 3322 // Fetch the map and check if array is in fast case. | |
| 3323 // Check that object doesn't require security checks and | |
| 3324 // has no indexed interceptor. | |
| 3325 __ CmpObjectType(object, JS_ARRAY_TYPE, temp); | |
| 3326 __ j(not_equal, &slow_case); | |
| 3327 __ test_b(FieldOperand(temp, Map::kBitFieldOffset), | |
| 3328 KeyedLoadIC::kSlowCaseBitFieldMask); | |
| 3329 __ j(not_zero, &slow_case); | |
| 3330 | |
| 3331 // Check the object's elements are in fast case and writable. | |
| 3332 __ mov(elements, FieldOperand(object, JSObject::kElementsOffset)); | |
| 3333 __ cmp(FieldOperand(elements, HeapObject::kMapOffset), | |
| 3334 Immediate(isolate()->factory()->fixed_array_map())); | |
| 3335 __ j(not_equal, &slow_case); | |
| 3336 | |
| 3337 // Check that both indices are smis. | |
| 3338 __ mov(index_1, Operand(esp, 1 * kPointerSize)); | |
| 3339 __ mov(index_2, Operand(esp, 0)); | |
| 3340 __ mov(temp, index_1); | |
| 3341 __ or_(temp, index_2); | |
| 3342 __ JumpIfNotSmi(temp, &slow_case); | |
| 3343 | |
| 3344 // Check that both indices are valid. | |
| 3345 __ mov(temp, FieldOperand(object, JSArray::kLengthOffset)); | |
| 3346 __ cmp(temp, index_1); | |
| 3347 __ j(below_equal, &slow_case); | |
| 3348 __ cmp(temp, index_2); | |
| 3349 __ j(below_equal, &slow_case); | |
| 3350 | |
| 3351 // Bring addresses into index1 and index2. | |
| 3352 __ lea(index_1, CodeGenerator::FixedArrayElementOperand(elements, index_1)); | |
| 3353 __ lea(index_2, CodeGenerator::FixedArrayElementOperand(elements, index_2)); | |
| 3354 | |
| 3355 // Swap elements. Use object and temp as scratch registers. | |
| 3356 __ mov(object, Operand(index_1, 0)); | |
| 3357 __ mov(temp, Operand(index_2, 0)); | |
| 3358 __ mov(Operand(index_2, 0), object); | |
| 3359 __ mov(Operand(index_1, 0), temp); | |
| 3360 | |
| 3361 Label no_remembered_set; | |
| 3362 __ CheckPageFlag(elements, | |
| 3363 temp, | |
| 3364 1 << MemoryChunk::SCAN_ON_SCAVENGE, | |
| 3365 not_zero, | |
| 3366 &no_remembered_set, | |
| 3367 Label::kNear); | |
| 3368 // Possible optimization: do a check that both values are Smis | |
| 3369 // (or them and test against Smi mask.) | |
| 3370 | |
| 3371 // We are swapping two objects in an array and the incremental marker never | |
| 3372 // pauses in the middle of scanning a single object. Therefore the | |
| 3373 // incremental marker is not disturbed, so we don't need to call the | |
| 3374 // RecordWrite stub that notifies the incremental marker. | |
| 3375 __ RememberedSetHelper(elements, | |
| 3376 index_1, | |
| 3377 temp, | |
| 3378 kDontSaveFPRegs, | |
| 3379 MacroAssembler::kFallThroughAtEnd); | |
| 3380 __ RememberedSetHelper(elements, | |
| 3381 index_2, | |
| 3382 temp, | |
| 3383 kDontSaveFPRegs, | |
| 3384 MacroAssembler::kFallThroughAtEnd); | |
| 3385 | |
| 3386 __ bind(&no_remembered_set); | |
| 3387 | |
| 3388 // We are done. Drop elements from the stack, and return undefined. | |
| 3389 __ add(esp, Immediate(3 * kPointerSize)); | |
| 3390 __ mov(eax, isolate()->factory()->undefined_value()); | |
| 3391 __ jmp(&done); | |
| 3392 | |
| 3393 __ bind(&slow_case); | |
| 3394 __ CallRuntime(Runtime::kSwapElements, 3); | |
| 3395 | |
| 3396 __ bind(&done); | |
| 3397 context()->Plug(eax); | |
| 3398 } | |
| 3399 | |
| 3400 | |
| 3401 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { | 3308 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { |
| 3402 ZoneList<Expression*>* args = expr->arguments(); | 3309 ZoneList<Expression*>* args = expr->arguments(); |
| 3403 ASSERT_EQ(2, args->length()); | 3310 ASSERT_EQ(2, args->length()); |
| 3404 | 3311 |
| 3405 ASSERT_NE(NULL, args->at(0)->AsLiteral()); | 3312 ASSERT_NE(NULL, args->at(0)->AsLiteral()); |
| 3406 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); | 3313 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); |
| 3407 | 3314 |
| 3408 Handle<FixedArray> jsfunction_result_caches( | 3315 Handle<FixedArray> jsfunction_result_caches( |
| 3409 isolate()->global_context()->jsfunction_result_caches()); | 3316 isolate()->global_context()->jsfunction_result_caches()); |
| 3410 if (jsfunction_result_caches->length() <= cache_id) { | 3317 if (jsfunction_result_caches->length() <= cache_id) { |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4509 *context_length = 0; | 4416 *context_length = 0; |
| 4510 return previous_; | 4417 return previous_; |
| 4511 } | 4418 } |
| 4512 | 4419 |
| 4513 | 4420 |
| 4514 #undef __ | 4421 #undef __ |
| 4515 | 4422 |
| 4516 } } // namespace v8::internal | 4423 } } // namespace v8::internal |
| 4517 | 4424 |
| 4518 #endif // V8_TARGET_ARCH_IA32 | 4425 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |