Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/ia32/ic-ia32.cc

Issue 2144006: Cardmarking writebarrier. (Closed)
Patch Set: change NewSpace and SemiSpace Contains to match HasHeapObjectTag Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); 297 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC);
298 } 298 }
299 299
300 300
301 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { 301 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
302 // ----------- S t a t e ------------- 302 // ----------- S t a t e -------------
303 // -- eax : key 303 // -- eax : key
304 // -- edx : receiver 304 // -- edx : receiver
305 // -- esp[0] : return address 305 // -- esp[0] : return address
306 // ----------------------------------- 306 // -----------------------------------
307 Label slow, check_string, index_int, index_string; 307 Label slow, check_string, index_smi, index_string;
308 Label check_pixel_array, probe_dictionary; 308 Label check_pixel_array, probe_dictionary;
309 Label check_number_dictionary; 309 Label check_number_dictionary;
310 310
311 // Check that the object isn't a smi. 311 // Check that the object isn't a smi.
312 __ test(edx, Immediate(kSmiTagMask)); 312 __ test(edx, Immediate(kSmiTagMask));
313 __ j(zero, &slow, not_taken); 313 __ j(zero, &slow, not_taken);
314 314
315 // Get the map of the receiver. 315 // Get the map of the receiver.
316 __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset)); 316 __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset));
317 317
318 // Check bit field. 318 // Check bit field.
319 __ movzx_b(ebx, FieldOperand(ecx, Map::kBitFieldOffset)); 319 __ movzx_b(ebx, FieldOperand(ecx, Map::kBitFieldOffset));
320 __ test(ebx, Immediate(kSlowCaseBitFieldMask)); 320 __ test(ebx, Immediate(kSlowCaseBitFieldMask));
321 __ j(not_zero, &slow, not_taken); 321 __ j(not_zero, &slow, not_taken);
322 // Check that the object is some kind of JS object EXCEPT JS Value type. 322 // Check that the object is some kind of JS object EXCEPT JS Value type.
323 // In the case that the object is a value-wrapper object, 323 // In the case that the object is a value-wrapper object,
324 // we enter the runtime system to make sure that indexing 324 // we enter the runtime system to make sure that indexing
325 // into string objects work as intended. 325 // into string objects work as intended.
326 ASSERT(JS_OBJECT_TYPE > JS_VALUE_TYPE); 326 ASSERT(JS_OBJECT_TYPE > JS_VALUE_TYPE);
327 __ CmpInstanceType(ecx, JS_OBJECT_TYPE); 327 __ CmpInstanceType(ecx, JS_OBJECT_TYPE);
328 __ j(below, &slow, not_taken); 328 __ j(below, &slow, not_taken);
329 // Check that the key is a smi. 329 // Check that the key is a smi.
330 __ test(eax, Immediate(kSmiTagMask)); 330 __ test(eax, Immediate(kSmiTagMask));
331 __ j(not_zero, &check_string, not_taken); 331 __ j(not_zero, &check_string, not_taken);
332 __ mov(ebx, eax);
333 __ SmiUntag(ebx);
334 // Get the elements array of the object. 332 // Get the elements array of the object.
335 __ bind(&index_int); 333 __ bind(&index_smi);
336 __ mov(ecx, FieldOperand(edx, JSObject::kElementsOffset)); 334 __ mov(ecx, FieldOperand(edx, JSObject::kElementsOffset));
337 // Check that the object is in fast mode (not dictionary). 335 // Check that the object is in fast mode (not dictionary).
338 __ CheckMap(ecx, Factory::fixed_array_map(), &check_pixel_array, true); 336 __ CheckMap(ecx, Factory::fixed_array_map(), &check_pixel_array, true);
339 // Check that the key (index) is within bounds. 337 // Check that the key (index) is within bounds.
340 __ cmp(ebx, FieldOperand(ecx, FixedArray::kLengthOffset)); 338 __ cmp(eax, FieldOperand(ecx, FixedArray::kLengthOffset));
341 __ j(above_equal, &slow); 339 __ j(above_equal, &slow);
342 // Fast case: Do the load. 340 // Fast case: Do the load.
343 __ mov(ecx, FieldOperand(ecx, ebx, times_4, FixedArray::kHeaderSize)); 341 ASSERT((kPointerSize == 4) && (kSmiTagSize == 1) && (kSmiTag == 0));
342 __ mov(ecx, FieldOperand(ecx, eax, times_2, FixedArray::kHeaderSize));
344 __ cmp(Operand(ecx), Immediate(Factory::the_hole_value())); 343 __ cmp(Operand(ecx), Immediate(Factory::the_hole_value()));
345 // In case the loaded value is the_hole we have to consult GetProperty 344 // In case the loaded value is the_hole we have to consult GetProperty
346 // to ensure the prototype chain is searched. 345 // to ensure the prototype chain is searched.
347 __ j(equal, &slow); 346 __ j(equal, &slow);
348 __ mov(eax, ecx); 347 __ mov(eax, ecx);
349 __ IncrementCounter(&Counters::keyed_load_generic_smi, 1); 348 __ IncrementCounter(&Counters::keyed_load_generic_smi, 1);
350 __ ret(0); 349 __ ret(0);
351 350
352 __ bind(&check_pixel_array); 351 __ bind(&check_pixel_array);
353 // Check whether the elements is a pixel array. 352 // Check whether the elements is a pixel array.
354 // edx: receiver 353 // edx: receiver
355 // ebx: untagged index
356 // eax: key 354 // eax: key
357 // ecx: elements 355 // ecx: elements
356 __ mov(ebx, eax);
357 __ SmiUntag(ebx);
358 __ CheckMap(ecx, Factory::pixel_array_map(), &check_number_dictionary, true); 358 __ CheckMap(ecx, Factory::pixel_array_map(), &check_number_dictionary, true);
359 __ cmp(ebx, FieldOperand(ecx, PixelArray::kLengthOffset)); 359 __ cmp(ebx, FieldOperand(ecx, PixelArray::kLengthOffset));
360 __ j(above_equal, &slow); 360 __ j(above_equal, &slow);
361 __ mov(eax, FieldOperand(ecx, PixelArray::kExternalPointerOffset)); 361 __ mov(eax, FieldOperand(ecx, PixelArray::kExternalPointerOffset));
362 __ movzx_b(eax, Operand(eax, ebx, times_1, 0)); 362 __ movzx_b(eax, Operand(eax, ebx, times_1, 0));
363 __ SmiTag(eax); 363 __ SmiTag(eax);
364 __ ret(0); 364 __ ret(0);
365 365
366 __ bind(&check_number_dictionary); 366 __ bind(&check_number_dictionary);
367 // Check whether the elements is a number dictionary. 367 // Check whether the elements is a number dictionary.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1); 478 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1);
479 __ ret(0); 479 __ ret(0);
480 480
481 // If the hash field contains an array index pick it out. The assert checks 481 // If the hash field contains an array index pick it out. The assert checks
482 // that the constants for the maximum number of digits for an array index 482 // that the constants for the maximum number of digits for an array index
483 // cached in the hash field and the number of bits reserved for it does not 483 // cached in the hash field and the number of bits reserved for it does not
484 // conflict. 484 // conflict.
485 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 485 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
486 (1 << String::kArrayIndexValueBits)); 486 (1 << String::kArrayIndexValueBits));
487 __ bind(&index_string); 487 __ bind(&index_string);
488 __ and_(ebx, String::kArrayIndexHashMask); 488 // We want the smi-tagged index in eax. kArrayIndexValueMask has zeros in
489 __ shr(ebx, String::kHashShift); 489 // the low kHashShift bits.
490 __ jmp(&index_int); 490 ASSERT(String::kHashShift >= kSmiTagSize);
491 __ and_(ebx, String::kArrayIndexValueMask);
492 __ shr(ebx, String::kHashShift - kSmiTagSize);
493 __ mov(eax, ebx);
494 __ jmp(&index_smi);
491 } 495 }
492 496
493 497
494 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { 498 void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
495 // ----------- S t a t e ------------- 499 // ----------- S t a t e -------------
496 // -- eax : key (index) 500 // -- eax : key (index)
497 // -- edx : receiver 501 // -- edx : receiver
498 // -- esp[0] : return address 502 // -- esp[0] : return address
499 // ----------------------------------- 503 // -----------------------------------
500 Label miss; 504 Label miss;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 __ CmpInstanceType(edi, FIRST_JS_OBJECT_TYPE); 789 __ CmpInstanceType(edi, FIRST_JS_OBJECT_TYPE);
786 __ j(below, &slow, not_taken); 790 __ j(below, &slow, not_taken);
787 791
788 // Object case: Check key against length in the elements array. 792 // Object case: Check key against length in the elements array.
789 // eax: value 793 // eax: value
790 // edx: JSObject 794 // edx: JSObject
791 // ecx: key (a smi) 795 // ecx: key (a smi)
792 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); 796 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset));
793 // Check that the object is in fast mode (not dictionary). 797 // Check that the object is in fast mode (not dictionary).
794 __ CheckMap(edi, Factory::fixed_array_map(), &check_pixel_array, true); 798 __ CheckMap(edi, Factory::fixed_array_map(), &check_pixel_array, true);
795 __ mov(ebx, Operand(ecx)); 799 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset));
796 __ SmiUntag(ebx);
797 __ cmp(ebx, FieldOperand(edi, Array::kLengthOffset));
798 __ j(below, &fast, taken); 800 __ j(below, &fast, taken);
799 801
800 // Slow case: call runtime. 802 // Slow case: call runtime.
801 __ bind(&slow); 803 __ bind(&slow);
802 GenerateRuntimeSetProperty(masm); 804 GenerateRuntimeSetProperty(masm);
803 805
804 // Check whether the elements is a pixel array. 806 // Check whether the elements is a pixel array.
805 __ bind(&check_pixel_array); 807 __ bind(&check_pixel_array);
806 // eax: value 808 // eax: value
807 // ecx: key 809 // ecx: key (a smi)
808 // edx: receiver 810 // edx: receiver
809 // edi: elements array 811 // edi: elements array
810 __ CheckMap(edi, Factory::pixel_array_map(), &slow, true); 812 __ CheckMap(edi, Factory::pixel_array_map(), &slow, true);
811 // Check that the value is a smi. If a conversion is needed call into the 813 // Check that the value is a smi. If a conversion is needed call into the
812 // runtime to convert and clamp. 814 // runtime to convert and clamp.
813 __ test(eax, Immediate(kSmiTagMask)); 815 __ test(eax, Immediate(kSmiTagMask));
814 __ j(not_zero, &slow); 816 __ j(not_zero, &slow);
815 __ mov(ebx, ecx); 817 __ mov(ebx, ecx);
816 __ SmiUntag(ebx); 818 __ SmiUntag(ebx);
817 __ cmp(ebx, FieldOperand(edi, PixelArray::kLengthOffset)); 819 __ cmp(ebx, FieldOperand(edi, PixelArray::kLengthOffset));
(...skipping 15 matching lines...) Expand all
833 // Extra capacity case: Check if there is extra capacity to 835 // Extra capacity case: Check if there is extra capacity to
834 // perform the store and update the length. Used for adding one 836 // perform the store and update the length. Used for adding one
835 // element to the array by writing to array[array.length]. 837 // element to the array by writing to array[array.length].
836 __ bind(&extra); 838 __ bind(&extra);
837 // eax: value 839 // eax: value
838 // edx: receiver, a JSArray 840 // edx: receiver, a JSArray
839 // ecx: key, a smi. 841 // ecx: key, a smi.
840 // edi: receiver->elements, a FixedArray 842 // edi: receiver->elements, a FixedArray
841 // flags: compare (ecx, edx.length()) 843 // flags: compare (ecx, edx.length())
842 __ j(not_equal, &slow, not_taken); // do not leave holes in the array 844 __ j(not_equal, &slow, not_taken); // do not leave holes in the array
843 __ mov(ebx, ecx); 845 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset));
844 __ SmiUntag(ebx); // untag
845 __ cmp(ebx, FieldOperand(edi, Array::kLengthOffset));
846 __ j(above_equal, &slow, not_taken); 846 __ j(above_equal, &slow, not_taken);
847 // Add 1 to receiver->length, and go to fast array write. 847 // Add 1 to receiver->length, and go to fast array write.
848 __ add(FieldOperand(edx, JSArray::kLengthOffset), 848 __ add(FieldOperand(edx, JSArray::kLengthOffset),
849 Immediate(1 << kSmiTagSize)); 849 Immediate(Smi::FromInt(1)));
850 __ jmp(&fast); 850 __ jmp(&fast);
851 851
852 // Array case: Get the length and the elements array from the JS 852 // Array case: Get the length and the elements array from the JS
853 // array. Check that the array is in fast mode; if it is the 853 // array. Check that the array is in fast mode; if it is the
854 // length is always a smi. 854 // length is always a smi.
855 __ bind(&array); 855 __ bind(&array);
856 // eax: value 856 // eax: value
857 // edx: receiver, a JSArray 857 // edx: receiver, a JSArray
858 // ecx: key, a smi. 858 // ecx: key, a smi.
859 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); 859 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset));
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss)); 1640 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss));
1641 __ TailCallExternalReference(ref, 3, 1); 1641 __ TailCallExternalReference(ref, 3, 1);
1642 } 1642 }
1643 1643
1644 #undef __ 1644 #undef __
1645 1645
1646 1646
1647 } } // namespace v8::internal 1647 } } // namespace v8::internal
1648 1648
1649 #endif // V8_TARGET_ARCH_IA32 1649 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | src/spaces.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698