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

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

Issue 9969196: Make SubStringStub more robust wrt unsafe arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 8 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 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 6144 matching lines...) Expand 10 before | Expand all | Expand 10 after
6155 // ebx: instance type 6155 // ebx: instance type
6156 6156
6157 // Calculate length of sub string using the smi values. 6157 // Calculate length of sub string using the smi values.
6158 __ mov(ecx, Operand(esp, 1 * kPointerSize)); // To index. 6158 __ mov(ecx, Operand(esp, 1 * kPointerSize)); // To index.
6159 __ JumpIfNotSmi(ecx, &runtime); 6159 __ JumpIfNotSmi(ecx, &runtime);
6160 __ mov(edx, Operand(esp, 2 * kPointerSize)); // From index. 6160 __ mov(edx, Operand(esp, 2 * kPointerSize)); // From index.
6161 __ JumpIfNotSmi(edx, &runtime); 6161 __ JumpIfNotSmi(edx, &runtime);
6162 __ sub(ecx, edx); 6162 __ sub(ecx, edx);
6163 __ cmp(ecx, FieldOperand(eax, String::kLengthOffset)); 6163 __ cmp(ecx, FieldOperand(eax, String::kLengthOffset));
6164 Label not_original_string; 6164 Label not_original_string;
6165 __ j(not_equal, &not_original_string, Label::kNear); 6165 // Shorter than original string's length: an actual substring.
6166 __ j(below, &not_original_string, Label::kNear);
6167 // Longer than original string's length or negative: unsafe arguments.
6168 __ j(above, &runtime);
6169 // Return original string.
6166 Counters* counters = masm->isolate()->counters(); 6170 Counters* counters = masm->isolate()->counters();
6167 __ IncrementCounter(counters->sub_string_native(), 1); 6171 __ IncrementCounter(counters->sub_string_native(), 1);
6168 __ ret(3 * kPointerSize); 6172 __ ret(3 * kPointerSize);
6169 __ bind(&not_original_string); 6173 __ bind(&not_original_string);
6170 6174
6171 // eax: string 6175 // eax: string
6172 // ebx: instance type 6176 // ebx: instance type
6173 // ecx: sub string length (smi) 6177 // ecx: sub string length (smi)
6174 // edx: from index (smi) 6178 // edx: from index (smi)
6175 // Deal with different string types: update the index if necessary 6179 // Deal with different string types: update the index if necessary
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
7379 false); 7383 false);
7380 __ pop(edx); 7384 __ pop(edx);
7381 __ ret(0); 7385 __ ret(0);
7382 } 7386 }
7383 7387
7384 #undef __ 7388 #undef __
7385 7389
7386 } } // namespace v8::internal 7390 } } // namespace v8::internal
7387 7391
7388 #endif // V8_TARGET_ARCH_IA32 7392 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698