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

Unified Diff: src/ic.cc

Issue 8733: Merged bleeding_edge r599:645 into regexp2000. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/regexp2000/
Patch Set: Created 12 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ic.h ('k') | src/ic-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ic.cc
===================================================================
--- src/ic.cc (revision 645)
+++ src/ic.cc (working copy)
@@ -453,20 +453,22 @@
}
if (FLAG_use_ic) {
- // Use specialized code for getting the length of strings.
- if (object->IsString() && name->Equals(Heap::length_symbol())) {
+ // Use specialized code for getting the length of strings and
+ // string wrapper objects. The length property of string wrapper
+ // objects is read-only and therefore always returns the length of
+ // the underlying string value. See ECMA-262 15.5.5.1.
+ if ((object->IsString() || object->IsStringWrapper()) &&
+ name->Equals(Heap::length_symbol())) {
+ HandleScope scope;
+ // Get the string if we have a string wrapper object.
+ if (object->IsJSValue()) {
+ object = Handle<Object>(Handle<JSValue>::cast(object)->value());
+ }
#ifdef DEBUG
if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n");
#endif
Code* target = NULL;
- if (object->IsShortString()) {
- target = Builtins::builtin(Builtins::LoadIC_ShortStringLength);
- } else if (object->IsMediumString()) {
- target = Builtins::builtin(Builtins::LoadIC_MediumStringLength);
- } else {
- ASSERT(object->IsLongString());
- target = Builtins::builtin(Builtins::LoadIC_LongStringLength);
- }
+ target = Builtins::builtin(Builtins::LoadIC_StringLength);
set_target(target);
StubCache::Set(*name, HeapObject::cast(*object)->map(), target);
return Smi::FromInt(String::cast(*object)->length());
@@ -637,15 +639,7 @@
if (object->IsString() && name->Equals(Heap::length_symbol())) {
Handle<String> string = Handle<String>::cast(object);
Object* code = NULL;
- if (string->IsShortString()) {
- code = StubCache::ComputeKeyedLoadShortStringLength(*name, *string);
- } else if (string->IsMediumString()) {
- code =
- StubCache::ComputeKeyedLoadMediumStringLength(*name, *string);
- } else {
- ASSERT(string->IsLongString());
- code = StubCache::ComputeKeyedLoadLongStringLength(*name, *string);
- }
+ code = StubCache::ComputeKeyedLoadStringLength(*name, *string);
if (code->IsFailure()) return code;
set_target(Code::cast(code));
#ifdef DEBUG
« no previous file with comments | « src/ic.h ('k') | src/ic-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698