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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 // Need to collect. Call into runtime system. | 316 // Need to collect. Call into runtime system. |
317 __ bind(&gc); | 317 __ bind(&gc); |
318 __ TailCallRuntime(Runtime::kPushBlockContext, 2, 1); | 318 __ TailCallRuntime(Runtime::kPushBlockContext, 2, 1); |
319 } | 319 } |
320 | 320 |
321 | 321 |
322 static void GenerateFastCloneShallowArrayCommon( | 322 static void GenerateFastCloneShallowArrayCommon( |
323 MacroAssembler* masm, | 323 MacroAssembler* masm, |
324 int length, | 324 int length, |
325 FastCloneShallowArrayStub::Mode mode, | 325 FastCloneShallowArrayStub::Mode mode, |
326 AllocationSiteInfoMode allocation_site_info_mode, | 326 AllocationSiteMode allocation_site_mode, |
327 Label* fail) { | 327 Label* fail) { |
328 // Registers on entry: | 328 // Registers on entry: |
329 // | 329 // |
330 // ecx: boilerplate literal array. | 330 // ecx: boilerplate literal array. |
331 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS); | 331 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS); |
332 | 332 |
333 // All sizes here are multiples of kPointerSize. | 333 // All sizes here are multiples of kPointerSize. |
334 int elements_size = 0; | 334 int elements_size = 0; |
335 if (length > 0) { | 335 if (length > 0) { |
336 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS | 336 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS |
337 ? FixedDoubleArray::SizeFor(length) | 337 ? FixedDoubleArray::SizeFor(length) |
338 : FixedArray::SizeFor(length); | 338 : FixedArray::SizeFor(length); |
339 } | 339 } |
340 int size = JSArray::kSize; | 340 int size = JSArray::kSize; |
341 int allocation_info_start = size; | 341 int allocation_info_start = size; |
342 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { | 342 if (allocation_site_mode == TRACK_ALLOCATION_SITE) { |
343 size += AllocationSiteInfo::kSize; | 343 size += AllocationSiteInfo::kSize; |
344 } | 344 } |
345 size += elements_size; | 345 size += elements_size; |
346 | 346 |
347 // Allocate both the JS array and the elements array in one big | 347 // Allocate both the JS array and the elements array in one big |
348 // allocation. This avoids multiple limit checks. | 348 // allocation. This avoids multiple limit checks. |
349 AllocationFlags flags = TAG_OBJECT; | 349 AllocationFlags flags = TAG_OBJECT; |
350 if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) { | 350 if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) { |
351 flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags); | 351 flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags); |
352 } | 352 } |
353 __ AllocateInNewSpace(size, eax, ebx, edx, fail, flags); | 353 __ AllocateInNewSpace(size, eax, ebx, edx, fail, flags); |
354 | 354 |
355 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { | 355 if (allocation_site_mode == TRACK_ALLOCATION_SITE) { |
356 __ mov(FieldOperand(eax, allocation_info_start), | 356 __ mov(FieldOperand(eax, allocation_info_start), |
357 Immediate(Handle<Map>(masm->isolate()->heap()-> | 357 Immediate(Handle<Map>(masm->isolate()->heap()-> |
358 allocation_site_info_map()))); | 358 allocation_site_info_map()))); |
359 __ mov(FieldOperand(eax, allocation_info_start + kPointerSize), ecx); | 359 __ mov(FieldOperand(eax, allocation_info_start + kPointerSize), ecx); |
360 } | 360 } |
361 | 361 |
362 // Copy the JS array part. | 362 // Copy the JS array part. |
363 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { | 363 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { |
364 if ((i != JSArray::kElementsOffset) || (length == 0)) { | 364 if ((i != JSArray::kElementsOffset) || (length == 0)) { |
365 __ mov(ebx, FieldOperand(ecx, i)); | 365 __ mov(ebx, FieldOperand(ecx, i)); |
366 __ mov(FieldOperand(eax, i), ebx); | 366 __ mov(FieldOperand(eax, i), ebx); |
367 } | 367 } |
368 } | 368 } |
369 | 369 |
370 if (length > 0) { | 370 if (length > 0) { |
371 // Get hold of the elements array of the boilerplate and setup the | 371 // Get hold of the elements array of the boilerplate and setup the |
372 // elements pointer in the resulting object. | 372 // elements pointer in the resulting object. |
373 __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset)); | 373 __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset)); |
374 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { | 374 if (allocation_site_mode == TRACK_ALLOCATION_SITE) { |
375 __ lea(edx, Operand(eax, JSArray::kSize + AllocationSiteInfo::kSize)); | 375 __ lea(edx, Operand(eax, JSArray::kSize + AllocationSiteInfo::kSize)); |
376 } else { | 376 } else { |
377 __ lea(edx, Operand(eax, JSArray::kSize)); | 377 __ lea(edx, Operand(eax, JSArray::kSize)); |
378 } | 378 } |
379 __ mov(FieldOperand(eax, JSArray::kElementsOffset), edx); | 379 __ mov(FieldOperand(eax, JSArray::kElementsOffset), edx); |
380 | 380 |
381 // Copy the elements array. | 381 // Copy the elements array. |
382 if (mode == FastCloneShallowArrayStub::CLONE_ELEMENTS) { | 382 if (mode == FastCloneShallowArrayStub::CLONE_ELEMENTS) { |
383 for (int i = 0; i < elements_size; i += kPointerSize) { | 383 for (int i = 0; i < elements_size; i += kPointerSize) { |
384 __ mov(ebx, FieldOperand(ecx, i)); | 384 __ mov(ebx, FieldOperand(ecx, i)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 STATIC_ASSERT(kSmiTag == 0); | 418 STATIC_ASSERT(kSmiTag == 0); |
419 __ mov(ecx, FieldOperand(ecx, eax, times_half_pointer_size, | 419 __ mov(ecx, FieldOperand(ecx, eax, times_half_pointer_size, |
420 FixedArray::kHeaderSize)); | 420 FixedArray::kHeaderSize)); |
421 Factory* factory = masm->isolate()->factory(); | 421 Factory* factory = masm->isolate()->factory(); |
422 __ cmp(ecx, factory->undefined_value()); | 422 __ cmp(ecx, factory->undefined_value()); |
423 Label slow_case; | 423 Label slow_case; |
424 __ j(equal, &slow_case); | 424 __ j(equal, &slow_case); |
425 | 425 |
426 FastCloneShallowArrayStub::Mode mode = mode_; | 426 FastCloneShallowArrayStub::Mode mode = mode_; |
427 // ecx is boilerplate object. | 427 // ecx is boilerplate object. |
428 AllocationSiteInfoMode allocation_site_info_mode = | |
429 DONT_TRACK_ALLOCATION_SITE_INFO; | |
430 if (mode == CLONE_ANY_ELEMENTS_WITH_ALLOCATION_SITE_INFO) { | |
431 mode = CLONE_ANY_ELEMENTS; | |
432 allocation_site_info_mode = TRACK_ALLOCATION_SITE_INFO; | |
433 } | |
434 | |
435 if (mode == CLONE_ANY_ELEMENTS) { | 428 if (mode == CLONE_ANY_ELEMENTS) { |
436 Label double_elements, check_fast_elements; | 429 Label double_elements, check_fast_elements; |
437 __ mov(ebx, FieldOperand(ecx, JSArray::kElementsOffset)); | 430 __ mov(ebx, FieldOperand(ecx, JSArray::kElementsOffset)); |
438 __ CheckMap(ebx, factory->fixed_cow_array_map(), | 431 __ CheckMap(ebx, factory->fixed_cow_array_map(), |
439 &check_fast_elements, DONT_DO_SMI_CHECK); | 432 &check_fast_elements, DONT_DO_SMI_CHECK); |
440 GenerateFastCloneShallowArrayCommon(masm, 0, | 433 GenerateFastCloneShallowArrayCommon(masm, 0, COPY_ON_WRITE_ELEMENTS, |
441 COPY_ON_WRITE_ELEMENTS, | 434 allocation_site_mode_, |
442 allocation_site_info_mode, | |
443 &slow_case); | 435 &slow_case); |
444 __ ret(3 * kPointerSize); | 436 __ ret(3 * kPointerSize); |
445 | 437 |
446 __ bind(&check_fast_elements); | 438 __ bind(&check_fast_elements); |
447 __ CheckMap(ebx, factory->fixed_array_map(), | 439 __ CheckMap(ebx, factory->fixed_array_map(), |
448 &double_elements, DONT_DO_SMI_CHECK); | 440 &double_elements, DONT_DO_SMI_CHECK); |
449 GenerateFastCloneShallowArrayCommon(masm, length_, | 441 GenerateFastCloneShallowArrayCommon(masm, length_, CLONE_ELEMENTS, |
450 CLONE_ELEMENTS, | 442 allocation_site_mode_, |
451 allocation_site_info_mode, | |
452 &slow_case); | 443 &slow_case); |
453 __ ret(3 * kPointerSize); | 444 __ ret(3 * kPointerSize); |
454 | 445 |
455 __ bind(&double_elements); | 446 __ bind(&double_elements); |
456 mode = CLONE_DOUBLE_ELEMENTS; | 447 mode = CLONE_DOUBLE_ELEMENTS; |
457 // Fall through to generate the code to handle double elements. | 448 // Fall through to generate the code to handle double elements. |
458 } | 449 } |
459 | 450 |
460 if (FLAG_debug_code) { | 451 if (FLAG_debug_code) { |
461 const char* message; | 452 const char* message; |
(...skipping 10 matching lines...) Expand all Loading... |
472 expected_map = factory->fixed_cow_array_map(); | 463 expected_map = factory->fixed_cow_array_map(); |
473 } | 464 } |
474 __ push(ecx); | 465 __ push(ecx); |
475 __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset)); | 466 __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset)); |
476 __ cmp(FieldOperand(ecx, HeapObject::kMapOffset), expected_map); | 467 __ cmp(FieldOperand(ecx, HeapObject::kMapOffset), expected_map); |
477 __ Assert(equal, message); | 468 __ Assert(equal, message); |
478 __ pop(ecx); | 469 __ pop(ecx); |
479 } | 470 } |
480 | 471 |
481 GenerateFastCloneShallowArrayCommon(masm, length_, mode, | 472 GenerateFastCloneShallowArrayCommon(masm, length_, mode, |
482 allocation_site_info_mode, &slow_case); | 473 allocation_site_mode_, |
| 474 &slow_case); |
| 475 |
483 // Return and remove the on-stack parameters. | 476 // Return and remove the on-stack parameters. |
484 __ ret(3 * kPointerSize); | 477 __ ret(3 * kPointerSize); |
485 | 478 |
486 __ bind(&slow_case); | 479 __ bind(&slow_case); |
487 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); | 480 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); |
488 } | 481 } |
489 | 482 |
490 | 483 |
491 void FastCloneShallowObjectStub::Generate(MacroAssembler* masm) { | 484 void FastCloneShallowObjectStub::Generate(MacroAssembler* masm) { |
492 // Stack layout on entry: | 485 // Stack layout on entry: |
(...skipping 7050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7543 // Restore ecx. | 7536 // Restore ecx. |
7544 __ pop(ecx); | 7537 __ pop(ecx); |
7545 __ ret(0); | 7538 __ ret(0); |
7546 } | 7539 } |
7547 | 7540 |
7548 #undef __ | 7541 #undef __ |
7549 | 7542 |
7550 } } // namespace v8::internal | 7543 } } // namespace v8::internal |
7551 | 7544 |
7552 #endif // V8_TARGET_ARCH_IA32 | 7545 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |