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

Side by Side Diff: src/ic.cc

Issue 8620: Allow inline caching for getting the length of string wrapper objects. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 1 month 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
« no previous file with comments | « no previous file | src/ic-arm.cc » ('j') | src/ic-arm.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 446
447 447
448 Object* LoadIC::Load(State state, Handle<Object> object, Handle<String> name) { 448 Object* LoadIC::Load(State state, Handle<Object> object, Handle<String> name) {
449 // If the object is undefined or null it's illegal to try to get any 449 // If the object is undefined or null it's illegal to try to get any
450 // of its properties; throw a TypeError in that case. 450 // of its properties; throw a TypeError in that case.
451 if (object->IsUndefined() || object->IsNull()) { 451 if (object->IsUndefined() || object->IsNull()) {
452 return TypeError("non_object_property_load", object, name); 452 return TypeError("non_object_property_load", object, name);
453 } 453 }
454 454
455 if (FLAG_use_ic) { 455 if (FLAG_use_ic) {
456 // Use specialized code for getting the length of strings. 456 // Use specialized code for getting the length of strings and
457 if (object->IsString() && name->Equals(Heap::length_symbol())) { 457 // string wrapper objects. The length property of string wrapper
458 // objects is read-only and therefore always returns the length of
459 // the underlying string value. See ECMA-262 15.5.5.1.
460 if ((object->IsString() || object->IsStringWrapper()) &&
461 name->Equals(Heap::length_symbol())) {
462 HandleScope scope;
463 // Get the string if we have a string wrapper object.
464 if (object->IsJSValue()) {
465 object = Handle<Object>(Handle<JSValue>::cast(object)->value());
466 }
458 #ifdef DEBUG 467 #ifdef DEBUG
459 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n"); 468 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n");
460 #endif 469 #endif
461 Code* target = NULL; 470 Code* target = NULL;
462 target = Builtins::builtin(Builtins::LoadIC_StringLength); 471 target = Builtins::builtin(Builtins::LoadIC_StringLength);
463 set_target(target); 472 set_target(target);
464 StubCache::Set(*name, HeapObject::cast(*object)->map(), target); 473 StubCache::Set(*name, HeapObject::cast(*object)->map(), target);
465 return Smi::FromInt(String::cast(*object)->length()); 474 return Smi::FromInt(String::cast(*object)->length());
466 } 475 }
467 476
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 #undef ADDR 1186 #undef ADDR
1178 }; 1187 };
1179 1188
1180 1189
1181 Address IC::AddressFromUtilityId(IC::UtilityId id) { 1190 Address IC::AddressFromUtilityId(IC::UtilityId id) {
1182 return IC_utilities[id]; 1191 return IC_utilities[id];
1183 } 1192 }
1184 1193
1185 1194
1186 } } // namespace v8::internal 1195 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/ic-arm.cc » ('j') | src/ic-arm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698