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

Side by Side Diff: src/objects.cc

Issue 32003006: Handlify Heap::AllocateInitialMap method. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 9877 matching lines...) Expand 10 before | Expand all | Expand 10 after
9888 : native_context->strict_mode_function_map())); 9888 : native_context->strict_mode_function_map()));
9889 9889
9890 set_map(no_prototype_map); 9890 set_map(no_prototype_map);
9891 set_prototype_or_initial_map(no_prototype_map->GetHeap()->the_hole_value()); 9891 set_prototype_or_initial_map(no_prototype_map->GetHeap()->the_hole_value());
9892 } 9892 }
9893 9893
9894 9894
9895 void JSFunction::EnsureHasInitialMap(Handle<JSFunction> function) { 9895 void JSFunction::EnsureHasInitialMap(Handle<JSFunction> function) {
9896 if (function->has_initial_map()) return; 9896 if (function->has_initial_map()) return;
9897 Isolate* isolate = function->GetIsolate(); 9897 Isolate* isolate = function->GetIsolate();
9898 Handle<Map> initial_map = isolate->factory()->NewInitialMap(function); 9898
9899 function->set_initial_map(*initial_map); 9899 // First create a new map with the size and number of in-object properties
9900 initial_map->set_constructor(*function); 9900 // suggested by the function.
9901 InstanceType instance_type;
9902 int instance_size;
9903 int in_object_properties;
9904 if (function->shared()->is_generator()) {
9905 instance_type = JS_GENERATOR_OBJECT_TYPE;
9906 instance_size = JSGeneratorObject::kSize;
9907 in_object_properties = 0;
9908 } else {
9909 instance_type = JS_OBJECT_TYPE;
9910 instance_size = function->shared()->CalculateInstanceSize();
9911 in_object_properties = function->shared()->CalculateInObjectProperties();
9912 }
9913 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size);
9914
9915 // Fetch or allocate prototype.
9916 Handle<Object> prototype;
9917 if (function->has_instance_prototype()) {
9918 prototype = handle(function->instance_prototype(), isolate);
9919 } else {
9920 prototype = isolate->factory()->NewFunctionPrototype(function);
9921 }
9922 map->set_inobject_properties(in_object_properties);
9923 map->set_unused_property_fields(in_object_properties);
9924 map->set_prototype(*prototype);
9925 ASSERT(map->has_fast_object_elements());
9926
9927 if (!function->shared()->is_generator()) {
9928 function->shared()->StartInobjectSlackTracking(*map);
9929 }
9930
9931 // Finally link initial map and constructor function.
9932 function->set_initial_map(*map);
9933 map->set_constructor(*function);
9901 } 9934 }
9902 9935
9903 9936
9904 void JSFunction::SetInstanceClassName(String* name) { 9937 void JSFunction::SetInstanceClassName(String* name) {
9905 shared()->set_instance_class_name(name); 9938 shared()->set_instance_class_name(name);
9906 } 9939 }
9907 9940
9908 9941
9909 void JSFunction::PrintName(FILE* out) { 9942 void JSFunction::PrintName(FILE* out) {
9910 SmartArrayPointer<char> name = shared()->DebugName()->ToCString(); 9943 SmartArrayPointer<char> name = shared()->DebugName()->ToCString();
(...skipping 6484 matching lines...) Expand 10 before | Expand all | Expand 10 after
16395 #define ERROR_MESSAGES_TEXTS(C, T) T, 16428 #define ERROR_MESSAGES_TEXTS(C, T) T,
16396 static const char* error_messages_[] = { 16429 static const char* error_messages_[] = {
16397 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16430 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16398 }; 16431 };
16399 #undef ERROR_MESSAGES_TEXTS 16432 #undef ERROR_MESSAGES_TEXTS
16400 return error_messages_[reason]; 16433 return error_messages_[reason];
16401 } 16434 }
16402 16435
16403 16436
16404 } } // namespace v8::internal 16437 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698