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

Side by Side Diff: src/ic.cc

Issue 225823003: Implement handlified String::Equals and Name::Equals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: refactored StringToDouble Created 6 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
« no previous file with comments | « src/ia32/lithium-codegen-ia32.cc ('k') | src/json-parser.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 // 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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 Handle<String> name) { 540 Handle<String> name) {
541 // If the object is undefined or null it's illegal to try to get any 541 // If the object is undefined or null it's illegal to try to get any
542 // of its properties; throw a TypeError in that case. 542 // of its properties; throw a TypeError in that case.
543 if (object->IsUndefined() || object->IsNull()) { 543 if (object->IsUndefined() || object->IsNull()) {
544 return TypeError("non_object_property_load", object, name); 544 return TypeError("non_object_property_load", object, name);
545 } 545 }
546 546
547 if (FLAG_use_ic) { 547 if (FLAG_use_ic) {
548 // Use specialized code for getting prototype of functions. 548 // Use specialized code for getting prototype of functions.
549 if (object->IsJSFunction() && 549 if (object->IsJSFunction() &&
550 name->Equals(isolate()->heap()->prototype_string()) && 550 String::Equals(isolate()->factory()->prototype_string(), name) &&
551 Handle<JSFunction>::cast(object)->should_have_prototype()) { 551 Handle<JSFunction>::cast(object)->should_have_prototype()) {
552 Handle<Code> stub; 552 Handle<Code> stub;
553 if (state() == UNINITIALIZED) { 553 if (state() == UNINITIALIZED) {
554 stub = pre_monomorphic_stub(); 554 stub = pre_monomorphic_stub();
555 } else if (state() == PREMONOMORPHIC) { 555 } else if (state() == PREMONOMORPHIC) {
556 FunctionPrototypeStub function_prototype_stub(kind()); 556 FunctionPrototypeStub function_prototype_stub(kind());
557 stub = function_prototype_stub.GetCode(isolate()); 557 stub = function_prototype_stub.GetCode(isolate());
558 } else if (state() != MEGAMORPHIC) { 558 } else if (state() != MEGAMORPHIC) {
559 ASSERT(state() != GENERIC); 559 ASSERT(state() != GENERIC);
560 stub = megamorphic_stub(); 560 stub = megamorphic_stub();
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 882
883 return code; 883 return code;
884 } 884 }
885 885
886 886
887 Handle<Code> LoadIC::CompileHandler(LookupResult* lookup, 887 Handle<Code> LoadIC::CompileHandler(LookupResult* lookup,
888 Handle<Object> object, 888 Handle<Object> object,
889 Handle<String> name, 889 Handle<String> name,
890 Handle<Object> unused, 890 Handle<Object> unused,
891 InlineCacheHolderFlag cache_holder) { 891 InlineCacheHolderFlag cache_holder) {
892 if (object->IsString() && name->Equals(isolate()->heap()->length_string())) { 892 if (object->IsString() &&
893 String::Equals(isolate()->factory()->length_string(), name)) {
893 int length_index = String::kLengthOffset / kPointerSize; 894 int length_index = String::kLengthOffset / kPointerSize;
894 return SimpleFieldLoad(length_index); 895 return SimpleFieldLoad(length_index);
895 } 896 }
896 897
897 if (object->IsStringWrapper() && 898 if (object->IsStringWrapper() &&
898 name->Equals(isolate()->heap()->length_string())) { 899 String::Equals(isolate()->factory()->length_string(), name)) {
899 if (kind() == Code::LOAD_IC) { 900 if (kind() == Code::LOAD_IC) {
900 StringLengthStub string_length_stub; 901 StringLengthStub string_length_stub;
901 return string_length_stub.GetCode(isolate()); 902 return string_length_stub.GetCode(isolate());
902 } else { 903 } else {
903 KeyedStringLengthStub string_length_stub; 904 KeyedStringLengthStub string_length_stub;
904 return string_length_stub.GetCode(isolate()); 905 return string_length_stub.GetCode(isolate());
905 } 906 }
906 } 907 }
907 908
908 Handle<HeapType> type = CurrentTypeOf(object, isolate()); 909 Handle<HeapType> type = CurrentTypeOf(object, isolate());
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 } 1207 }
1207 1208
1208 // If the object is undefined or null it's illegal to try to set any 1209 // If the object is undefined or null it's illegal to try to set any
1209 // properties on it; throw a TypeError in that case. 1210 // properties on it; throw a TypeError in that case.
1210 if (object->IsUndefined() || object->IsNull()) { 1211 if (object->IsUndefined() || object->IsNull()) {
1211 return TypeError("non_object_property_store", object, name); 1212 return TypeError("non_object_property_store", object, name);
1212 } 1213 }
1213 1214
1214 // The length property of string values is read-only. Throw in strict mode. 1215 // The length property of string values is read-only. Throw in strict mode.
1215 if (strict_mode() == STRICT && object->IsString() && 1216 if (strict_mode() == STRICT && object->IsString() &&
1216 name->Equals(isolate()->heap()->length_string())) { 1217 String::Equals(isolate()->factory()->length_string(), name)) {
1217 return TypeError("strict_read_only_property", object, name); 1218 return TypeError("strict_read_only_property", object, name);
1218 } 1219 }
1219 1220
1220 // Ignore other stores where the receiver is not a JSObject. 1221 // Ignore other stores where the receiver is not a JSObject.
1221 // TODO(1475): Must check prototype chains of object wrappers. 1222 // TODO(1475): Must check prototype chains of object wrappers.
1222 if (!object->IsJSObject()) return *value; 1223 if (!object->IsJSObject()) return *value;
1223 1224
1224 Handle<JSObject> receiver = Handle<JSObject>::cast(object); 1225 Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1225 1226
1226 // Check if the given name is an array index. 1227 // Check if the given name is an array index.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 receiver, holder, name, Handle<JSFunction>::cast(setter)); 1394 receiver, holder, name, Handle<JSFunction>::cast(setter));
1394 } 1395 }
1395 // TODO(dcarney): Handle correctly. 1396 // TODO(dcarney): Handle correctly.
1396 if (callback->IsDeclaredAccessorInfo()) break; 1397 if (callback->IsDeclaredAccessorInfo()) break;
1397 ASSERT(callback->IsForeign()); 1398 ASSERT(callback->IsForeign());
1398 1399
1399 // Use specialized code for setting the length of arrays with fast 1400 // Use specialized code for setting the length of arrays with fast
1400 // properties. Slow properties might indicate redefinition of the length 1401 // properties. Slow properties might indicate redefinition of the length
1401 // property. 1402 // property.
1402 if (receiver->IsJSArray() && 1403 if (receiver->IsJSArray() &&
1403 name->Equals(isolate()->heap()->length_string()) && 1404 String::Equals(isolate()->factory()->length_string(), name) &&
1404 Handle<JSArray>::cast(receiver)->AllowsSetElementsLength() && 1405 Handle<JSArray>::cast(receiver)->AllowsSetElementsLength() &&
1405 receiver->HasFastProperties()) { 1406 receiver->HasFastProperties()) {
1406 return compiler.CompileStoreArrayLength(receiver, lookup, name); 1407 return compiler.CompileStoreArrayLength(receiver, lookup, name);
1407 } 1408 }
1408 1409
1409 // No IC support for old-style native accessors. 1410 // No IC support for old-style native accessors.
1410 break; 1411 break;
1411 } 1412 }
1412 case INTERCEPTOR: 1413 case INTERCEPTOR:
1413 if (kind() == Code::KEYED_STORE_IC) break; 1414 if (kind() == Code::KEYED_STORE_IC) break;
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
2839 #undef ADDR 2840 #undef ADDR
2840 }; 2841 };
2841 2842
2842 2843
2843 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2844 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2844 return IC_utilities[id]; 2845 return IC_utilities[id];
2845 } 2846 }
2846 2847
2847 2848
2848 } } // namespace v8::internal 2849 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.cc ('k') | src/json-parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698