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

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

Issue 1185343005: Revert of Revert of [strong] Implement strong mode restrictions on property access (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « src/ic/ia32/handler-compiler-ia32.cc ('k') | src/ic/ic.h » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/ic/ic.h" 10 #include "src/ic/ic.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 __ CmpInstanceType(map, JS_OBJECT_TYPE); 166 __ CmpInstanceType(map, JS_OBJECT_TYPE);
167 __ j(below, slow); 167 __ j(below, slow);
168 } 168 }
169 169
170 170
171 // Loads an indexed element from a fast case array. 171 // Loads an indexed element from a fast case array.
172 static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver, 172 static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver,
173 Register key, Register scratch, 173 Register key, Register scratch,
174 Register scratch2, Register result, 174 Register scratch2, Register result,
175 Label* slow) { 175 Label* slow, LanguageMode language_mode) {
176 // Register use: 176 // Register use:
177 // receiver - holds the receiver and is unchanged. 177 // receiver - holds the receiver and is unchanged.
178 // key - holds the key and is unchanged (must be a smi). 178 // key - holds the key and is unchanged (must be a smi).
179 // Scratch registers: 179 // Scratch registers:
180 // scratch - used to hold elements of the receiver and the loaded value. 180 // scratch - used to hold elements of the receiver and the loaded value.
181 // scratch2 - holds maps and prototypes during prototype chain check. 181 // scratch2 - holds maps and prototypes during prototype chain check.
182 // result - holds the result on exit if the load succeeds and 182 // result - holds the result on exit if the load succeeds and
183 // we fall through. 183 // we fall through.
184 Label check_prototypes, check_next_prototype; 184 Label check_prototypes, check_next_prototype;
185 Label done, in_bounds, return_undefined; 185 Label done, in_bounds, absent;
186 186
187 __ mov(scratch, FieldOperand(receiver, JSObject::kElementsOffset)); 187 __ mov(scratch, FieldOperand(receiver, JSObject::kElementsOffset));
188 __ AssertFastElements(scratch); 188 __ AssertFastElements(scratch);
189 189
190 // Check that the key (index) is within bounds. 190 // Check that the key (index) is within bounds.
191 __ cmp(key, FieldOperand(scratch, FixedArray::kLengthOffset)); 191 __ cmp(key, FieldOperand(scratch, FixedArray::kLengthOffset));
192 __ j(below, &in_bounds); 192 __ j(below, &in_bounds);
193 // Out-of-bounds. Check the prototype chain to see if we can just return 193 // Out-of-bounds. Check the prototype chain to see if we can just return
194 // 'undefined'. 194 // 'undefined'.
195 __ cmp(key, 0); 195 __ cmp(key, 0);
196 __ j(less, slow); // Negative keys can't take the fast OOB path. 196 __ j(less, slow); // Negative keys can't take the fast OOB path.
197 __ bind(&check_prototypes); 197 __ bind(&check_prototypes);
198 __ mov(scratch2, FieldOperand(receiver, HeapObject::kMapOffset)); 198 __ mov(scratch2, FieldOperand(receiver, HeapObject::kMapOffset));
199 __ bind(&check_next_prototype); 199 __ bind(&check_next_prototype);
200 __ mov(scratch2, FieldOperand(scratch2, Map::kPrototypeOffset)); 200 __ mov(scratch2, FieldOperand(scratch2, Map::kPrototypeOffset));
201 // scratch2: current prototype 201 // scratch2: current prototype
202 __ cmp(scratch2, masm->isolate()->factory()->null_value()); 202 __ cmp(scratch2, masm->isolate()->factory()->null_value());
203 __ j(equal, &return_undefined); 203 __ j(equal, &absent);
204 __ mov(scratch, FieldOperand(scratch2, JSObject::kElementsOffset)); 204 __ mov(scratch, FieldOperand(scratch2, JSObject::kElementsOffset));
205 __ mov(scratch2, FieldOperand(scratch2, HeapObject::kMapOffset)); 205 __ mov(scratch2, FieldOperand(scratch2, HeapObject::kMapOffset));
206 // scratch: elements of current prototype 206 // scratch: elements of current prototype
207 // scratch2: map of current prototype 207 // scratch2: map of current prototype
208 __ CmpInstanceType(scratch2, JS_OBJECT_TYPE); 208 __ CmpInstanceType(scratch2, JS_OBJECT_TYPE);
209 __ j(below, slow); 209 __ j(below, slow);
210 __ test_b( 210 __ test_b(
211 FieldOperand(scratch2, Map::kBitFieldOffset), 211 FieldOperand(scratch2, Map::kBitFieldOffset),
212 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor)); 212 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor));
213 __ j(not_zero, slow); 213 __ j(not_zero, slow);
214 __ cmp(scratch, masm->isolate()->factory()->empty_fixed_array()); 214 __ cmp(scratch, masm->isolate()->factory()->empty_fixed_array());
215 __ j(not_equal, slow); 215 __ j(not_equal, slow);
216 __ jmp(&check_next_prototype); 216 __ jmp(&check_next_prototype);
217 217
218 __ bind(&return_undefined); 218 __ bind(&absent);
219 __ mov(result, masm->isolate()->factory()->undefined_value()); 219 if (is_strong(language_mode)) {
220 __ jmp(&done); 220 // Strong mode accesses must throw in this case, so call the runtime.
221 __ jmp(slow);
222 } else {
223 __ mov(result, masm->isolate()->factory()->undefined_value());
224 __ jmp(&done);
225 }
221 226
222 __ bind(&in_bounds); 227 __ bind(&in_bounds);
223 // Fast case: Do the load. 228 // Fast case: Do the load.
224 STATIC_ASSERT((kPointerSize == 4) && (kSmiTagSize == 1) && (kSmiTag == 0)); 229 STATIC_ASSERT((kPointerSize == 4) && (kSmiTagSize == 1) && (kSmiTag == 0));
225 __ mov(scratch, FieldOperand(scratch, key, times_2, FixedArray::kHeaderSize)); 230 __ mov(scratch, FieldOperand(scratch, key, times_2, FixedArray::kHeaderSize));
226 __ cmp(scratch, Immediate(masm->isolate()->factory()->the_hole_value())); 231 __ cmp(scratch, Immediate(masm->isolate()->factory()->the_hole_value()));
227 // In case the loaded value is the_hole we have to check the prototype chain. 232 // In case the loaded value is the_hole we have to check the prototype chain.
228 __ j(equal, &check_prototypes); 233 __ j(equal, &check_prototypes);
229 __ Move(result, scratch); 234 __ Move(result, scratch);
230 __ bind(&done); 235 __ bind(&done);
(...skipping 25 matching lines...) Expand all
256 // bit test is enough. 261 // bit test is enough.
257 STATIC_ASSERT(kNotInternalizedTag != 0); 262 STATIC_ASSERT(kNotInternalizedTag != 0);
258 __ test_b(FieldOperand(map, Map::kInstanceTypeOffset), 263 __ test_b(FieldOperand(map, Map::kInstanceTypeOffset),
259 kIsNotInternalizedMask); 264 kIsNotInternalizedMask);
260 __ j(not_zero, not_unique); 265 __ j(not_zero, not_unique);
261 266
262 __ bind(&unique); 267 __ bind(&unique);
263 } 268 }
264 269
265 270
266 void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm) { 271 void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm,
272 LanguageMode language_mode) {
267 // The return address is on the stack. 273 // The return address is on the stack.
268 Label slow, check_name, index_smi, index_name, property_array_property; 274 Label slow, check_name, index_smi, index_name, property_array_property;
269 Label probe_dictionary, check_number_dictionary; 275 Label probe_dictionary, check_number_dictionary;
270 276
271 Register receiver = LoadDescriptor::ReceiverRegister(); 277 Register receiver = LoadDescriptor::ReceiverRegister();
272 Register key = LoadDescriptor::NameRegister(); 278 Register key = LoadDescriptor::NameRegister();
273 DCHECK(receiver.is(edx)); 279 DCHECK(receiver.is(edx));
274 DCHECK(key.is(ecx)); 280 DCHECK(key.is(ecx));
275 281
276 // Check that the key is a smi. 282 // Check that the key is a smi.
277 __ JumpIfNotSmi(key, &check_name); 283 __ JumpIfNotSmi(key, &check_name);
278 __ bind(&index_smi); 284 __ bind(&index_smi);
279 // Now the key is known to be a smi. This place is also jumped to from 285 // Now the key is known to be a smi. This place is also jumped to from
280 // where a numeric string is converted to a smi. 286 // where a numeric string is converted to a smi.
281 287
282 GenerateKeyedLoadReceiverCheck(masm, receiver, eax, 288 GenerateKeyedLoadReceiverCheck(masm, receiver, eax,
283 Map::kHasIndexedInterceptor, &slow); 289 Map::kHasIndexedInterceptor, &slow);
284 290
285 // Check the receiver's map to see if it has fast elements. 291 // Check the receiver's map to see if it has fast elements.
286 __ CheckFastElements(eax, &check_number_dictionary); 292 __ CheckFastElements(eax, &check_number_dictionary);
287 293
288 GenerateFastArrayLoad(masm, receiver, key, eax, ebx, eax, &slow); 294 GenerateFastArrayLoad(masm, receiver, key, eax, ebx, eax, &slow,
295 language_mode);
289 Isolate* isolate = masm->isolate(); 296 Isolate* isolate = masm->isolate();
290 Counters* counters = isolate->counters(); 297 Counters* counters = isolate->counters();
291 __ IncrementCounter(counters->keyed_load_generic_smi(), 1); 298 __ IncrementCounter(counters->keyed_load_generic_smi(), 1);
292 __ ret(0); 299 __ ret(0);
293 300
294 __ bind(&check_number_dictionary); 301 __ bind(&check_number_dictionary);
295 __ mov(ebx, key); 302 __ mov(ebx, key);
296 __ SmiUntag(ebx); 303 __ SmiUntag(ebx);
297 __ mov(eax, FieldOperand(receiver, JSObject::kElementsOffset)); 304 __ mov(eax, FieldOperand(receiver, JSObject::kElementsOffset));
298 305
(...skipping 11 matching lines...) Expand all
310 __ pop(receiver); 317 __ pop(receiver);
311 __ ret(0); 318 __ ret(0);
312 319
313 __ bind(&slow_pop_receiver); 320 __ bind(&slow_pop_receiver);
314 // Pop the receiver from the stack and jump to runtime. 321 // Pop the receiver from the stack and jump to runtime.
315 __ pop(receiver); 322 __ pop(receiver);
316 323
317 __ bind(&slow); 324 __ bind(&slow);
318 // Slow case: jump to runtime. 325 // Slow case: jump to runtime.
319 __ IncrementCounter(counters->keyed_load_generic_slow(), 1); 326 __ IncrementCounter(counters->keyed_load_generic_slow(), 1);
320 GenerateRuntimeGetProperty(masm); 327 GenerateSlow(masm);
321 328
322 __ bind(&check_name); 329 __ bind(&check_name);
323 GenerateKeyNameCheck(masm, key, eax, ebx, &index_name, &slow); 330 GenerateKeyNameCheck(masm, key, eax, ebx, &index_name, &slow);
324 331
325 GenerateKeyedLoadReceiverCheck(masm, receiver, eax, Map::kHasNamedInterceptor, 332 GenerateKeyedLoadReceiverCheck(masm, receiver, eax, Map::kHasNamedInterceptor,
326 &slow); 333 &slow);
327 334
328 // If the receiver is a fast-case object, check the stub cache. Otherwise 335 // If the receiver is a fast-case object, check the stub cache. Otherwise
329 // probe the dictionary. 336 // probe the dictionary.
330 __ mov(ebx, FieldOperand(receiver, JSObject::kPropertiesOffset)); 337 __ mov(ebx, FieldOperand(receiver, JSObject::kPropertiesOffset));
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 Label slow; 623 Label slow;
617 624
618 __ mov(dictionary, FieldOperand(LoadDescriptor::ReceiverRegister(), 625 __ mov(dictionary, FieldOperand(LoadDescriptor::ReceiverRegister(),
619 JSObject::kPropertiesOffset)); 626 JSObject::kPropertiesOffset));
620 GenerateDictionaryLoad(masm, &slow, dictionary, 627 GenerateDictionaryLoad(masm, &slow, dictionary,
621 LoadDescriptor::NameRegister(), edi, ebx, eax); 628 LoadDescriptor::NameRegister(), edi, ebx, eax);
622 __ ret(0); 629 __ ret(0);
623 630
624 // Dictionary load failed, go slow (but don't miss). 631 // Dictionary load failed, go slow (but don't miss).
625 __ bind(&slow); 632 __ bind(&slow);
626 GenerateRuntimeGetProperty(masm); 633 GenerateSlow(masm);
627 } 634 }
628 635
629 636
630 static void LoadIC_PushArgs(MacroAssembler* masm) { 637 static void LoadIC_PushArgs(MacroAssembler* masm) {
631 Register receiver = LoadDescriptor::ReceiverRegister(); 638 Register receiver = LoadDescriptor::ReceiverRegister();
632 Register name = LoadDescriptor::NameRegister(); 639 Register name = LoadDescriptor::NameRegister();
633 640
634 Register slot = LoadDescriptor::SlotRegister(); 641 Register slot = LoadDescriptor::SlotRegister();
635 Register vector = LoadWithVectorDescriptor::VectorRegister(); 642 Register vector = LoadWithVectorDescriptor::VectorRegister();
636 DCHECK(!edi.is(receiver) && !edi.is(name) && !edi.is(slot) && 643 DCHECK(!edi.is(receiver) && !edi.is(name) && !edi.is(slot) &&
(...skipping 14 matching lines...) Expand all
651 LoadIC_PushArgs(masm); 658 LoadIC_PushArgs(masm);
652 659
653 // Perform tail call to the entry. 660 // Perform tail call to the entry.
654 ExternalReference ref = 661 ExternalReference ref =
655 ExternalReference(IC_Utility(kLoadIC_Miss), masm->isolate()); 662 ExternalReference(IC_Utility(kLoadIC_Miss), masm->isolate());
656 int arg_count = 4; 663 int arg_count = 4;
657 __ TailCallExternalReference(ref, arg_count, 1); 664 __ TailCallExternalReference(ref, arg_count, 1);
658 } 665 }
659 666
660 667
661 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { 668 void LoadIC::GenerateSlow(MacroAssembler* masm) {
662 // Return address is on the stack. 669 // Return address is on the stack.
663 Register receiver = LoadDescriptor::ReceiverRegister(); 670 Register receiver = LoadDescriptor::ReceiverRegister();
664 Register name = LoadDescriptor::NameRegister(); 671 Register name = LoadDescriptor::NameRegister();
665 DCHECK(!ebx.is(receiver) && !ebx.is(name)); 672 DCHECK(!ebx.is(receiver) && !ebx.is(name));
666 673
667 __ pop(ebx); 674 __ pop(ebx);
668 __ push(receiver); 675 __ push(receiver);
669 __ push(name); 676 __ push(name);
670 __ push(ebx); 677 __ push(ebx);
671 678
672 // Perform tail call to the entry. 679 // Perform tail call to the entry.
673 __ TailCallRuntime(Runtime::kGetProperty, 2, 1); 680 ExternalReference ref =
681 ExternalReference(IC_Utility(kLoadIC_Slow), masm->isolate());
682 int arg_count = 2;
683 __ TailCallExternalReference(ref, arg_count, 1);
674 } 684 }
675 685
676 686
677 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { 687 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) {
678 // Return address is on the stack. 688 // Return address is on the stack.
679 __ IncrementCounter(masm->isolate()->counters()->keyed_load_miss(), 1); 689 __ IncrementCounter(masm->isolate()->counters()->keyed_load_miss(), 1);
680 690
681 LoadIC_PushArgs(masm); 691 LoadIC_PushArgs(masm);
682 692
683 // Perform tail call to the entry. 693 // Perform tail call to the entry.
684 ExternalReference ref = 694 ExternalReference ref =
685 ExternalReference(IC_Utility(kKeyedLoadIC_Miss), masm->isolate()); 695 ExternalReference(IC_Utility(kKeyedLoadIC_Miss), masm->isolate());
686 int arg_count = 4; 696 int arg_count = 4;
687 __ TailCallExternalReference(ref, arg_count, 1); 697 __ TailCallExternalReference(ref, arg_count, 1);
688 } 698 }
689 699
690 700
691 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { 701 void KeyedLoadIC::GenerateSlow(MacroAssembler* masm) {
692 // Return address is on the stack. 702 // Return address is on the stack.
693 Register receiver = LoadDescriptor::ReceiverRegister(); 703 Register receiver = LoadDescriptor::ReceiverRegister();
694 Register name = LoadDescriptor::NameRegister(); 704 Register name = LoadDescriptor::NameRegister();
695 DCHECK(!ebx.is(receiver) && !ebx.is(name)); 705 DCHECK(!ebx.is(receiver) && !ebx.is(name));
696 706
697 __ pop(ebx); 707 __ pop(ebx);
698 __ push(receiver); 708 __ push(receiver);
699 __ push(name); 709 __ push(name);
700 __ push(ebx); 710 __ push(ebx);
701 711
702 // Perform tail call to the entry. 712 // Perform tail call to the entry.
703 __ TailCallRuntime(Runtime::kKeyedGetProperty, 2, 1); 713 ExternalReference ref =
714 ExternalReference(IC_Utility(kKeyedLoadIC_Slow), masm->isolate());
715 int arg_count = 2;
716 __ TailCallExternalReference(ref, arg_count, 1);
704 } 717 }
705 718
706 719
707 void StoreIC::GenerateMegamorphic(MacroAssembler* masm) { 720 void StoreIC::GenerateMegamorphic(MacroAssembler* masm) {
708 // Return address is on the stack. 721 // Return address is on the stack.
709 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( 722 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags(
710 Code::ComputeHandlerFlags(Code::STORE_IC)); 723 Code::ComputeHandlerFlags(Code::STORE_IC));
711 masm->isolate()->stub_cache()->GenerateProbe( 724 masm->isolate()->stub_cache()->GenerateProbe(
712 masm, Code::STORE_IC, flags, false, StoreDescriptor::ReceiverRegister(), 725 masm, Code::STORE_IC, flags, false, StoreDescriptor::ReceiverRegister(),
713 StoreDescriptor::NameRegister(), ebx, no_reg); 726 StoreDescriptor::NameRegister(), ebx, no_reg);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 Condition cc = 861 Condition cc =
849 (check == ENABLE_INLINED_SMI_CHECK) 862 (check == ENABLE_INLINED_SMI_CHECK)
850 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) 863 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero)
851 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); 864 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry);
852 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); 865 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc);
853 } 866 }
854 } // namespace internal 867 } // namespace internal
855 } // namespace v8 868 } // namespace v8
856 869
857 #endif // V8_TARGET_ARCH_IA32 870 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ic/ia32/handler-compiler-ia32.cc ('k') | src/ic/ic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698