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

Side by Side Diff: src/ic.cc

Issue 6717018: Introduce accessors on builtins instance (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix tests and lint. Created 9 years, 9 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/ic.h ('k') | src/liveedit.cc » ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 HandleScope scope(isolate()); 871 HandleScope scope(isolate());
872 #ifdef DEBUG 872 #ifdef DEBUG
873 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n"); 873 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n");
874 #endif 874 #endif
875 if (state == PREMONOMORPHIC) { 875 if (state == PREMONOMORPHIC) {
876 if (object->IsString()) { 876 if (object->IsString()) {
877 Map* map = HeapObject::cast(*object)->map(); 877 Map* map = HeapObject::cast(*object)->map();
878 const int offset = String::kLengthOffset; 878 const int offset = String::kLengthOffset;
879 PatchInlinedLoad(address(), map, offset); 879 PatchInlinedLoad(address(), map, offset);
880 set_target(isolate()->builtins()->builtin( 880 set_target(isolate()->builtins()->builtin(
881 Builtins::LoadIC_StringLength)); 881 Builtins::kLoadIC_StringLength));
882 } else { 882 } else {
883 set_target(isolate()->builtins()->builtin( 883 set_target(isolate()->builtins()->builtin(
884 Builtins::LoadIC_StringWrapperLength)); 884 Builtins::kLoadIC_StringWrapperLength));
885 } 885 }
886 } else if (state == MONOMORPHIC && object->IsStringWrapper()) { 886 } else if (state == MONOMORPHIC && object->IsStringWrapper()) {
887 set_target(isolate()->builtins()->builtin( 887 set_target(isolate()->builtins()->builtin(
888 Builtins::LoadIC_StringWrapperLength)); 888 Builtins::kLoadIC_StringWrapperLength));
889 } else { 889 } else {
890 set_target(non_monomorphic_stub); 890 set_target(non_monomorphic_stub);
891 } 891 }
892 // Get the string if we have a string wrapper object. 892 // Get the string if we have a string wrapper object.
893 if (object->IsJSValue()) { 893 if (object->IsJSValue()) {
894 object = Handle<Object>(Handle<JSValue>::cast(object)->value(), 894 object = Handle<Object>(Handle<JSValue>::cast(object)->value(),
895 isolate()); 895 isolate());
896 } 896 }
897 return Smi::FromInt(String::cast(*object)->length()); 897 return Smi::FromInt(String::cast(*object)->length());
898 } 898 }
899 899
900 // Use specialized code for getting the length of arrays. 900 // Use specialized code for getting the length of arrays.
901 if (object->IsJSArray() && 901 if (object->IsJSArray() &&
902 name->Equals(isolate()->heap()->length_symbol())) { 902 name->Equals(isolate()->heap()->length_symbol())) {
903 #ifdef DEBUG 903 #ifdef DEBUG
904 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n"); 904 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n");
905 #endif 905 #endif
906 if (state == PREMONOMORPHIC) { 906 if (state == PREMONOMORPHIC) {
907 Map* map = HeapObject::cast(*object)->map(); 907 Map* map = HeapObject::cast(*object)->map();
908 const int offset = JSArray::kLengthOffset; 908 const int offset = JSArray::kLengthOffset;
909 PatchInlinedLoad(address(), map, offset); 909 PatchInlinedLoad(address(), map, offset);
910 set_target(isolate()->builtins()->builtin( 910 set_target(isolate()->builtins()->builtin(
911 Builtins::LoadIC_ArrayLength)); 911 Builtins::kLoadIC_ArrayLength));
912 } else { 912 } else {
913 set_target(non_monomorphic_stub); 913 set_target(non_monomorphic_stub);
914 } 914 }
915 return JSArray::cast(*object)->length(); 915 return JSArray::cast(*object)->length();
916 } 916 }
917 917
918 // Use specialized code for getting prototype of functions. 918 // Use specialized code for getting prototype of functions.
919 if (object->IsJSFunction() && 919 if (object->IsJSFunction() &&
920 name->Equals(isolate()->heap()->prototype_symbol()) && 920 name->Equals(isolate()->heap()->prototype_symbol()) &&
921 JSFunction::cast(*object)->should_have_prototype()) { 921 JSFunction::cast(*object)->should_have_prototype()) {
922 #ifdef DEBUG 922 #ifdef DEBUG
923 if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n"); 923 if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n");
924 #endif 924 #endif
925 if (state == PREMONOMORPHIC) { 925 if (state == PREMONOMORPHIC) {
926 set_target(isolate()->builtins()->builtin( 926 set_target(isolate()->builtins()->builtin(
927 Builtins::LoadIC_FunctionPrototype)); 927 Builtins::kLoadIC_FunctionPrototype));
928 } else { 928 } else {
929 set_target(non_monomorphic_stub); 929 set_target(non_monomorphic_stub);
930 } 930 }
931 return Accessors::FunctionGetPrototype(*object, 0); 931 return Accessors::FunctionGetPrototype(*object, 0);
932 } 932 }
933 } 933 }
934 934
935 // Check if the name is trivially convertible to an index and get 935 // Check if the name is trivially convertible to an index and get
936 // the element if so. 936 // the element if so.
937 uint32_t index; 937 uint32_t index;
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 } 1444 }
1445 1445
1446 // Use specialized code for setting the length of arrays. 1446 // Use specialized code for setting the length of arrays.
1447 if (receiver->IsJSArray() 1447 if (receiver->IsJSArray()
1448 && name->Equals(isolate()->heap()->length_symbol()) 1448 && name->Equals(isolate()->heap()->length_symbol())
1449 && receiver->AllowsSetElementsLength()) { 1449 && receiver->AllowsSetElementsLength()) {
1450 #ifdef DEBUG 1450 #ifdef DEBUG
1451 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n"); 1451 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n");
1452 #endif 1452 #endif
1453 Builtins::Name target = (strict_mode == kStrictMode) 1453 Builtins::Name target = (strict_mode == kStrictMode)
1454 ? Builtins::StoreIC_ArrayLength_Strict 1454 ? Builtins::kStoreIC_ArrayLength_Strict
1455 : Builtins::StoreIC_ArrayLength; 1455 : Builtins::kStoreIC_ArrayLength;
1456 set_target(isolate()->builtins()->builtin(target)); 1456 set_target(isolate()->builtins()->builtin(target));
1457 return receiver->SetProperty(*name, *value, NONE, strict_mode); 1457 return receiver->SetProperty(*name, *value, NONE, strict_mode);
1458 } 1458 }
1459 1459
1460 // Lookup the property locally in the receiver. 1460 // Lookup the property locally in the receiver.
1461 if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) { 1461 if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) {
1462 LookupResult lookup; 1462 LookupResult lookup;
1463 1463
1464 if (LookupForWrite(*receiver, *name, &lookup)) { 1464 if (LookupForWrite(*receiver, *name, &lookup)) {
1465 bool can_be_inlined = 1465 bool can_be_inlined =
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 #undef ADDR 2376 #undef ADDR
2377 }; 2377 };
2378 2378
2379 2379
2380 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2380 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2381 return IC_utilities[id]; 2381 return IC_utilities[id];
2382 } 2382 }
2383 2383
2384 2384
2385 } } // namespace v8::internal 2385 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/liveedit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698