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

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 6708085: Enable GVN for polymorphic loads by not expanding them at the HIR level. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2076 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 Register result = ToRegister(instr->result()); 2087 Register result = ToRegister(instr->result());
2088 if (instr->hydrogen()->is_in_object()) { 2088 if (instr->hydrogen()->is_in_object()) {
2089 __ movq(result, FieldOperand(object, instr->hydrogen()->offset())); 2089 __ movq(result, FieldOperand(object, instr->hydrogen()->offset()));
2090 } else { 2090 } else {
2091 __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset)); 2091 __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset));
2092 __ movq(result, FieldOperand(result, instr->hydrogen()->offset())); 2092 __ movq(result, FieldOperand(result, instr->hydrogen()->offset()));
2093 } 2093 }
2094 } 2094 }
2095 2095
2096 2096
2097 void LCodeGen::EmitLoadField(Register result,
2098 Register object,
2099 Handle<Map> type,
2100 Handle<String> name) {
2101 LookupResult lookup;
2102 type->LookupInDescriptors(NULL, *name, &lookup);
2103 ASSERT(lookup.IsProperty() && lookup.type() == FIELD);
2104 int index = lookup.GetLocalFieldIndexFromMap(*type);
2105 int offset = index * kPointerSize;
2106 if (index < 0) {
2107 // Negative property indices are in-object properties, indexed
2108 // from the end of the fixed part of the object.
2109 __ movq(result, FieldOperand(object, offset + type->instance_size()));
2110 } else {
2111 // Non-negative property indices are in the properties array.
2112 __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset));
2113 __ movq(result, FieldOperand(result, offset + FixedArray::kHeaderSize));
2114 }
2115 }
2116
2117
2118 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
2119 Register object = ToRegister(instr->object());
2120 Register result = ToRegister(instr->result());
2121
2122 int map_count = instr->hydrogen()->types()->length();
2123 Handle<String> name = instr->hydrogen()->name();
2124
2125 if (map_count == 0) {
2126 ASSERT(instr->hydrogen()->need_generic());
2127 __ Move(rcx, instr->hydrogen()->name());
2128 Handle<Code> ic(
2129 isolate()->builtins()->builtin(Builtins::LoadIC_Initialize));
2130 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2131 } else {
2132 NearLabel done;
2133 for (int i = 0; i < map_count - 1; ++i) {
2134 Handle<Map> map = instr->hydrogen()->types()->at(i);
2135 NearLabel next;
2136 __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map);
2137 __ j(not_equal, &next);
2138 EmitLoadField(result, object, map, name);
2139 __ jmp(&done);
2140 __ bind(&next);
2141 }
2142 Handle<Map> map = instr->hydrogen()->types()->last();
2143 __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map);
2144 if (instr->hydrogen()->need_generic()) {
2145 NearLabel generic;
2146 __ j(not_equal, &generic);
2147 EmitLoadField(result, object, map, name);
2148 __ jmp(&done);
2149 __ bind(&generic);
2150 __ Move(rcx, instr->hydrogen()->name());
2151 Handle<Code> ic(
2152 isolate()->builtins()->builtin(Builtins::LoadIC_Initialize));
2153 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2154 } else {
2155 DeoptimizeIf(not_equal, instr->environment());
2156 EmitLoadField(result, object, map, name);
2157 }
2158 __ bind(&done);
2159 }
2160 }
2161
2162
2097 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { 2163 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
2098 ASSERT(ToRegister(instr->object()).is(rax)); 2164 ASSERT(ToRegister(instr->object()).is(rax));
2099 ASSERT(ToRegister(instr->result()).is(rax)); 2165 ASSERT(ToRegister(instr->result()).is(rax));
2100 2166
2101 __ Move(rcx, instr->name()); 2167 __ Move(rcx, instr->name());
2102 Handle<Code> ic(isolate()->builtins()->builtin(Builtins::LoadIC_Initialize)); 2168 Handle<Code> ic(isolate()->builtins()->builtin(Builtins::LoadIC_Initialize));
2103 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2169 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2104 } 2170 }
2105 2171
2106 2172
(...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after
3819 RegisterEnvironmentForDeoptimization(environment); 3885 RegisterEnvironmentForDeoptimization(environment);
3820 ASSERT(osr_pc_offset_ == -1); 3886 ASSERT(osr_pc_offset_ == -1);
3821 osr_pc_offset_ = masm()->pc_offset(); 3887 osr_pc_offset_ = masm()->pc_offset();
3822 } 3888 }
3823 3889
3824 #undef __ 3890 #undef __
3825 3891
3826 } } // namespace v8::internal 3892 } } // namespace v8::internal
3827 3893
3828 #endif // V8_TARGET_ARCH_X64 3894 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698