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

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 10170030: Implement tracking and optimizations of packed arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 8 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2640 matching lines...) Expand 10 before | Expand all | Expand 10 after
2651 2651
2652 void MacroAssembler::CmpInstanceType(Register map, InstanceType type) { 2652 void MacroAssembler::CmpInstanceType(Register map, InstanceType type) {
2653 cmpb(FieldOperand(map, Map::kInstanceTypeOffset), 2653 cmpb(FieldOperand(map, Map::kInstanceTypeOffset),
2654 Immediate(static_cast<int8_t>(type))); 2654 Immediate(static_cast<int8_t>(type)));
2655 } 2655 }
2656 2656
2657 2657
2658 void MacroAssembler::CheckFastElements(Register map, 2658 void MacroAssembler::CheckFastElements(Register map,
2659 Label* fail, 2659 Label* fail,
2660 Label::Distance distance) { 2660 Label::Distance distance) {
2661 STATIC_ASSERT(FAST_SMI_ONLY_ELEMENTS == 0); 2661 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0);
2662 STATIC_ASSERT(FAST_ELEMENTS == 1); 2662 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1);
2663 STATIC_ASSERT(FAST_ELEMENTS == 2);
2664 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3);
2663 cmpb(FieldOperand(map, Map::kBitField2Offset), 2665 cmpb(FieldOperand(map, Map::kBitField2Offset),
2664 Immediate(Map::kMaximumBitField2FastElementValue)); 2666 Immediate(Map::kMaximumBitField2FastHoleyElementValue));
2665 j(above, fail, distance); 2667 j(above, fail, distance);
2666 } 2668 }
2667 2669
2668 2670
2669 void MacroAssembler::CheckFastObjectElements(Register map, 2671 void MacroAssembler::CheckFastObjectElements(Register map,
2670 Label* fail, 2672 Label* fail,
2671 Label::Distance distance) { 2673 Label::Distance distance) {
2672 STATIC_ASSERT(FAST_SMI_ONLY_ELEMENTS == 0); 2674 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0);
2673 STATIC_ASSERT(FAST_ELEMENTS == 1); 2675 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1);
2676 STATIC_ASSERT(FAST_ELEMENTS == 2);
2677 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3);
2674 cmpb(FieldOperand(map, Map::kBitField2Offset), 2678 cmpb(FieldOperand(map, Map::kBitField2Offset),
2675 Immediate(Map::kMaximumBitField2FastSmiOnlyElementValue)); 2679 Immediate(Map::kMaximumBitField2FastHoleySmiElementValue));
2676 j(below_equal, fail, distance); 2680 j(below_equal, fail, distance);
2677 cmpb(FieldOperand(map, Map::kBitField2Offset), 2681 cmpb(FieldOperand(map, Map::kBitField2Offset),
2678 Immediate(Map::kMaximumBitField2FastElementValue)); 2682 Immediate(Map::kMaximumBitField2FastHoleyElementValue));
2679 j(above, fail, distance); 2683 j(above, fail, distance);
2680 } 2684 }
2681 2685
2682 2686
2683 void MacroAssembler::CheckFastSmiOnlyElements(Register map, 2687 void MacroAssembler::CheckFastSmiElements(Register map,
2684 Label* fail, 2688 Label* fail,
2685 Label::Distance distance) { 2689 Label::Distance distance) {
2686 STATIC_ASSERT(FAST_SMI_ONLY_ELEMENTS == 0); 2690 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0);
2691 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1);
2687 cmpb(FieldOperand(map, Map::kBitField2Offset), 2692 cmpb(FieldOperand(map, Map::kBitField2Offset),
2688 Immediate(Map::kMaximumBitField2FastSmiOnlyElementValue)); 2693 Immediate(Map::kMaximumBitField2FastHoleySmiElementValue));
2689 j(above, fail, distance); 2694 j(above, fail, distance);
2690 } 2695 }
2691 2696
2692 2697
2693 void MacroAssembler::StoreNumberToDoubleElements( 2698 void MacroAssembler::StoreNumberToDoubleElements(
2694 Register maybe_number, 2699 Register maybe_number,
2695 Register elements, 2700 Register elements,
2696 Register index, 2701 Register index,
2697 XMMRegister xmm_scratch, 2702 XMMRegister xmm_scratch,
2698 Label* fail) { 2703 Label* fail) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2742 bind(&done); 2747 bind(&done);
2743 } 2748 }
2744 2749
2745 2750
2746 void MacroAssembler::CompareMap(Register obj, 2751 void MacroAssembler::CompareMap(Register obj,
2747 Handle<Map> map, 2752 Handle<Map> map,
2748 Label* early_success, 2753 Label* early_success,
2749 CompareMapMode mode) { 2754 CompareMapMode mode) {
2750 Cmp(FieldOperand(obj, HeapObject::kMapOffset), map); 2755 Cmp(FieldOperand(obj, HeapObject::kMapOffset), map);
2751 if (mode == ALLOW_ELEMENT_TRANSITION_MAPS) { 2756 if (mode == ALLOW_ELEMENT_TRANSITION_MAPS) {
2752 Map* transitioned_fast_element_map( 2757 ElementsKind kind = map->elements_kind();
2753 map->LookupElementsTransitionMap(FAST_ELEMENTS, NULL)); 2758 if (IsFastElementsKind(kind)) {
2754 ASSERT(transitioned_fast_element_map == NULL || 2759 bool packed = IsFastPackedElementsKind(kind);
2755 map->elements_kind() != FAST_ELEMENTS); 2760 Map* current_map = *map;
2756 if (transitioned_fast_element_map != NULL) { 2761 while (CanTransitionToMoreGeneralFastElementsKind(kind, packed)) {
2757 j(equal, early_success, Label::kNear); 2762 kind = GetNextMoreGeneralFastElementsKind(kind, packed);
2758 Cmp(FieldOperand(obj, HeapObject::kMapOffset), 2763 current_map = current_map->LookupElementsTransitionMap(kind, NULL);
2759 Handle<Map>(transitioned_fast_element_map)); 2764 if (!current_map) break;
2760 } 2765 j(equal, early_success, Label::kNear);
2761 2766 Cmp(FieldOperand(obj, HeapObject::kMapOffset),
2762 Map* transitioned_double_map( 2767 Handle<Map>(current_map));
2763 map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, NULL)); 2768 }
2764 ASSERT(transitioned_double_map == NULL ||
2765 map->elements_kind() == FAST_SMI_ONLY_ELEMENTS);
2766 if (transitioned_double_map != NULL) {
2767 j(equal, early_success, Label::kNear);
2768 Cmp(FieldOperand(obj, HeapObject::kMapOffset),
2769 Handle<Map>(transitioned_double_map));
2770 } 2769 }
2771 } 2770 }
2772 } 2771 }
2773 2772
2774 2773
2775 void MacroAssembler::CheckMap(Register obj, 2774 void MacroAssembler::CheckMap(Register obj,
2776 Handle<Map> map, 2775 Handle<Map> map,
2777 Label* fail, 2776 Label* fail,
2778 SmiCheckType smi_check_type, 2777 SmiCheckType smi_check_type,
2779 CompareMapMode mode) { 2778 CompareMapMode mode) {
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
4050 ElementsKind expected_kind, 4049 ElementsKind expected_kind,
4051 ElementsKind transitioned_kind, 4050 ElementsKind transitioned_kind,
4052 Register map_in_out, 4051 Register map_in_out,
4053 Register scratch, 4052 Register scratch,
4054 Label* no_map_match) { 4053 Label* no_map_match) {
4055 // Load the global or builtins object from the current context. 4054 // Load the global or builtins object from the current context.
4056 movq(scratch, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); 4055 movq(scratch, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)));
4057 movq(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset)); 4056 movq(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset));
4058 4057
4059 // Check that the function's map is the same as the expected cached map. 4058 // Check that the function's map is the same as the expected cached map.
4060 int expected_index = 4059 movq(scratch, Operand(scratch,
4061 Context::GetContextMapIndexFromElementsKind(expected_kind); 4060 Context::SlotOffset(Context::JS_ARRAY_MAPS_INDEX)));
4062 cmpq(map_in_out, Operand(scratch, Context::SlotOffset(expected_index))); 4061
4062 size_t offset = expected_kind * kPointerSize +
4063 FixedArrayBase::kHeaderSize;
4064 cmpq(map_in_out, FieldOperand(scratch, offset));
4063 j(not_equal, no_map_match); 4065 j(not_equal, no_map_match);
4064 4066
4065 // Use the transitioned cached map. 4067 // Use the transitioned cached map.
4066 int trans_index = 4068 offset = transitioned_kind * kPointerSize +
4067 Context::GetContextMapIndexFromElementsKind(transitioned_kind); 4069 FixedArrayBase::kHeaderSize;
4068 movq(map_in_out, Operand(scratch, Context::SlotOffset(trans_index))); 4070 movq(map_in_out, FieldOperand(scratch, offset));
4069 } 4071 }
4070 4072
4071 4073
4072 void MacroAssembler::LoadInitialArrayMap( 4074 void MacroAssembler::LoadInitialArrayMap(
4073 Register function_in, Register scratch, Register map_out) { 4075 Register function_in, Register scratch,
4076 Register map_out, bool can_have_holes) {
4074 ASSERT(!function_in.is(map_out)); 4077 ASSERT(!function_in.is(map_out));
4075 Label done; 4078 Label done;
4076 movq(map_out, FieldOperand(function_in, 4079 movq(map_out, FieldOperand(function_in,
4077 JSFunction::kPrototypeOrInitialMapOffset)); 4080 JSFunction::kPrototypeOrInitialMapOffset));
4078 if (!FLAG_smi_only_arrays) { 4081 if (!FLAG_smi_only_arrays) {
4079 LoadTransitionedArrayMapConditional(FAST_SMI_ONLY_ELEMENTS, 4082 ElementsKind kind = can_have_holes ? FAST_HOLEY_ELEMENTS : FAST_ELEMENTS;
4080 FAST_ELEMENTS, 4083 LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS,
4084 kind,
4081 map_out, 4085 map_out,
4082 scratch, 4086 scratch,
4083 &done); 4087 &done);
4088 } else if (can_have_holes) {
4089 LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS,
4090 FAST_HOLEY_SMI_ELEMENTS,
4091 map_out,
4092 scratch,
4093 &done);
4084 } 4094 }
4085 bind(&done); 4095 bind(&done);
4086 } 4096 }
4087 4097
4088 #ifdef _WIN64 4098 #ifdef _WIN64
4089 static const int kRegisterPassedArguments = 4; 4099 static const int kRegisterPassedArguments = 4;
4090 #else 4100 #else
4091 static const int kRegisterPassedArguments = 6; 4101 static const int kRegisterPassedArguments = 6;
4092 #endif 4102 #endif
4093 4103
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
4436 bind(&check_prototype); 4446 bind(&check_prototype);
4437 movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); 4447 movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset));
4438 cmpq(rcx, null_value); 4448 cmpq(rcx, null_value);
4439 j(not_equal, &next); 4449 j(not_equal, &next);
4440 } 4450 }
4441 4451
4442 4452
4443 } } // namespace v8::internal 4453 } } // namespace v8::internal
4444 4454
4445 #endif // V8_TARGET_ARCH_X64 4455 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698