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

Side by Side Diff: src/runtime.cc

Issue 8566009: Remove hidden prototype for builtin functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | « src/runtime.h ('k') | src/string.js » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 Object* V = args[1]; 876 Object* V = args[1];
877 while (true) { 877 while (true) {
878 Object* prototype = V->GetPrototype(); 878 Object* prototype = V->GetPrototype();
879 if (prototype->IsNull()) return isolate->heap()->false_value(); 879 if (prototype->IsNull()) return isolate->heap()->false_value();
880 if (O == prototype) return isolate->heap()->true_value(); 880 if (O == prototype) return isolate->heap()->true_value();
881 V = prototype; 881 V = prototype;
882 } 882 }
883 } 883 }
884 884
885 885
886 // Inserts an object as the hidden prototype of another object.
887 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHiddenPrototype) {
888 NoHandleAllocation ha;
889 ASSERT(args.length() == 2);
890 CONVERT_CHECKED(JSObject, jsobject, args[0]);
891 CONVERT_CHECKED(JSObject, proto, args[1]);
892
893 // Sanity checks. The old prototype (that we are replacing) could
894 // theoretically be null, but if it is not null then check that we
895 // didn't already install a hidden prototype here.
896 RUNTIME_ASSERT(!jsobject->GetPrototype()->IsHeapObject() ||
897 !HeapObject::cast(jsobject->GetPrototype())->map()->is_hidden_prototype());
898 RUNTIME_ASSERT(!proto->map()->is_hidden_prototype());
899
900 // Allocate up front before we start altering state in case we get a GC.
901 Object* map_or_failure;
902 { MaybeObject* maybe_map_or_failure = proto->map()->CopyDropTransitions();
903 if (!maybe_map_or_failure->ToObject(&map_or_failure)) {
904 return maybe_map_or_failure;
905 }
906 }
907 Map* new_proto_map = Map::cast(map_or_failure);
908
909 { MaybeObject* maybe_map_or_failure = jsobject->map()->CopyDropTransitions();
910 if (!maybe_map_or_failure->ToObject(&map_or_failure)) {
911 return maybe_map_or_failure;
912 }
913 }
914 Map* new_map = Map::cast(map_or_failure);
915
916 // Set proto's prototype to be the old prototype of the object.
917 new_proto_map->set_prototype(jsobject->GetPrototype());
918 proto->set_map(new_proto_map);
919 new_proto_map->set_is_hidden_prototype();
920
921 // Set the object's prototype to proto.
922 new_map->set_prototype(proto);
923 jsobject->set_map(new_map);
924
925 return isolate->heap()->undefined_value();
926 }
927
928
929 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConstructCall) { 886 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConstructCall) {
930 NoHandleAllocation ha; 887 NoHandleAllocation ha;
931 ASSERT(args.length() == 0); 888 ASSERT(args.length() == 0);
932 JavaScriptFrameIterator it(isolate); 889 JavaScriptFrameIterator it(isolate);
933 return isolate->heap()->ToBoolean(it.frame()->IsConstructor()); 890 return isolate->heap()->ToBoolean(it.frame()->IsConstructor());
934 } 891 }
935 892
936 893
937 // Recursively traverses hidden prototypes if property is not found 894 // Recursively traverses hidden prototypes if property is not found
938 static void GetOwnPropertyImplementation(JSObject* obj, 895 static void GetOwnPropertyImplementation(JSObject* obj,
(...skipping 12632 matching lines...) Expand 10 before | Expand all | Expand 10 after
13571 } else { 13528 } else {
13572 // Handle last resort GC and make sure to allow future allocations 13529 // Handle last resort GC and make sure to allow future allocations
13573 // to grow the heap without causing GCs (if possible). 13530 // to grow the heap without causing GCs (if possible).
13574 isolate->counters()->gc_last_resort_from_js()->Increment(); 13531 isolate->counters()->gc_last_resort_from_js()->Increment();
13575 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13532 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13576 } 13533 }
13577 } 13534 }
13578 13535
13579 13536
13580 } } // namespace v8::internal 13537 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698