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

Side by Side Diff: src/mips/code-stubs-mips.cc

Issue 8742012: MIPS: Catch non-string subject in RegExpExecStub. (Closed)
Patch Set: Created 9 years 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4728 matching lines...) Expand 10 before | Expand all | Expand 10 after
4739 __ Branch(&runtime, gt, a2, Operand(at)); 4739 __ Branch(&runtime, gt, a2, Operand(at));
4740 4740
4741 // Reset offset for possibly sliced string. 4741 // Reset offset for possibly sliced string.
4742 __ mov(t0, zero_reg); 4742 __ mov(t0, zero_reg);
4743 // subject: Subject string 4743 // subject: Subject string
4744 // regexp_data: RegExp data (FixedArray) 4744 // regexp_data: RegExp data (FixedArray)
4745 // Check the representation and encoding of the subject string. 4745 // Check the representation and encoding of the subject string.
4746 Label seq_string; 4746 Label seq_string;
4747 __ lw(a0, FieldMemOperand(subject, HeapObject::kMapOffset)); 4747 __ lw(a0, FieldMemOperand(subject, HeapObject::kMapOffset));
4748 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset)); 4748 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset));
4749 // First check for flat string. 4749 // First check for flat string. None of the following string type tests will
4750 // succeed if kIsNotStringTag is set.
4750 __ And(a1, a0, Operand(kIsNotStringMask | kStringRepresentationMask)); 4751 __ And(a1, a0, Operand(kIsNotStringMask | kStringRepresentationMask));
4751 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); 4752 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0);
4752 __ Branch(&seq_string, eq, a1, Operand(zero_reg)); 4753 __ Branch(&seq_string, eq, a1, Operand(zero_reg));
4753 4754
4754 // subject: Subject string 4755 // subject: Subject string
4755 // a0: instance type if Subject string 4756 // a0: instance type if Subject string
4756 // regexp_data: RegExp data (FixedArray) 4757 // regexp_data: RegExp data (FixedArray)
4758 // a1: whether subject is a string and if yes, its string representation
4757 // Check for flat cons string or sliced string. 4759 // Check for flat cons string or sliced string.
4758 // A flat cons string is a cons string where the second part is the empty 4760 // A flat cons string is a cons string where the second part is the empty
4759 // string. In that case the subject string is just the first part of the cons 4761 // string. In that case the subject string is just the first part of the cons
4760 // string. Also in this case the first part of the cons string is known to be 4762 // string. Also in this case the first part of the cons string is known to be
4761 // a sequential string or an external string. 4763 // a sequential string or an external string.
4762 // In the case of a sliced string its offset has to be taken into account. 4764 // In the case of a sliced string its offset has to be taken into account.
4763 Label cons_string, check_encoding; 4765 Label cons_string, check_encoding;
4764 STATIC_ASSERT(kConsStringTag < kExternalStringTag); 4766 STATIC_ASSERT(kConsStringTag < kExternalStringTag);
4765 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); 4767 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag);
4768 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag);
4766 __ Branch(&cons_string, lt, a1, Operand(kExternalStringTag)); 4769 __ Branch(&cons_string, lt, a1, Operand(kExternalStringTag));
4767 __ Branch(&runtime, eq, a1, Operand(kExternalStringTag)); 4770 __ Branch(&runtime, eq, a1, Operand(kExternalStringTag));
4768 4771
4772 // Catch non-string subject (should already have been guarded against).
4773 STATIC_ASSERT(kNotStringTag != 0);
4774 __ And(at, a1, Operand(kIsNotStringMask));
4775 __ Branch(&runtime, ne, at, Operand(zero_reg));
4776
4769 // String is sliced. 4777 // String is sliced.
4770 __ lw(t0, FieldMemOperand(subject, SlicedString::kOffsetOffset)); 4778 __ lw(t0, FieldMemOperand(subject, SlicedString::kOffsetOffset));
4771 __ sra(t0, t0, kSmiTagSize); 4779 __ sra(t0, t0, kSmiTagSize);
4772 __ lw(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); 4780 __ lw(subject, FieldMemOperand(subject, SlicedString::kParentOffset));
4773 // t5: offset of sliced string, smi-tagged. 4781 // t5: offset of sliced string, smi-tagged.
4774 __ jmp(&check_encoding); 4782 __ jmp(&check_encoding);
4775 // String is a cons string, check whether it is flat. 4783 // String is a cons string, check whether it is flat.
4776 __ bind(&cons_string); 4784 __ bind(&cons_string);
4777 __ lw(a0, FieldMemOperand(subject, ConsString::kSecondOffset)); 4785 __ lw(a0, FieldMemOperand(subject, ConsString::kSecondOffset));
4778 __ LoadRoot(a1, Heap::kEmptyStringRootIndex); 4786 __ LoadRoot(a1, Heap::kEmptyStringRootIndex);
(...skipping 2682 matching lines...) Expand 10 before | Expand all | Expand 10 after
7461 &slow_elements); 7469 &slow_elements);
7462 __ Ret(); 7470 __ Ret();
7463 } 7471 }
7464 7472
7465 7473
7466 #undef __ 7474 #undef __
7467 7475
7468 } } // namespace v8::internal 7476 } } // namespace v8::internal
7469 7477
7470 #endif // V8_TARGET_ARCH_MIPS 7478 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698