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

Side by Side Diff: src/runtime.cc

Issue 10780031: Grouping all map creation code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments Created 8 years, 5 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/objects-inl.h ('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 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 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 } 1286 }
1287 1287
1288 1288
1289 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) { 1289 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) {
1290 ASSERT(args.length() == 1); 1290 ASSERT(args.length() == 1);
1291 CONVERT_ARG_CHECKED(HeapObject, object, 0); 1291 CONVERT_ARG_CHECKED(HeapObject, object, 0);
1292 Map* old_map = object->map(); 1292 Map* old_map = object->map();
1293 bool needs_access_checks = old_map->is_access_check_needed(); 1293 bool needs_access_checks = old_map->is_access_check_needed();
1294 if (needs_access_checks) { 1294 if (needs_access_checks) {
1295 // Copy map so it won't interfere constructor's initial map. 1295 // Copy map so it won't interfere constructor's initial map.
1296 Object* new_map; 1296 Map* new_map;
1297 { MaybeObject* maybe_new_map = 1297 MaybeObject* maybe_new_map = old_map->Copy(DescriptorArray::MAY_BE_SHARED);
1298 old_map->CopyDropTransitions(DescriptorArray::MAY_BE_SHARED); 1298 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
1299 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
1300 }
1301 1299
1302 Map::cast(new_map)->set_is_access_check_needed(false); 1300 new_map->set_is_access_check_needed(false);
1303 object->set_map(Map::cast(new_map)); 1301 object->set_map(new_map);
1304 } 1302 }
1305 return isolate->heap()->ToBoolean(needs_access_checks); 1303 return isolate->heap()->ToBoolean(needs_access_checks);
1306 } 1304 }
1307 1305
1308 1306
1309 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { 1307 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) {
1310 ASSERT(args.length() == 1); 1308 ASSERT(args.length() == 1);
1311 CONVERT_ARG_CHECKED(HeapObject, object, 0); 1309 CONVERT_ARG_CHECKED(HeapObject, object, 0);
1312 Map* old_map = object->map(); 1310 Map* old_map = object->map();
1313 if (!old_map->is_access_check_needed()) { 1311 if (!old_map->is_access_check_needed()) {
1314 // Copy map so it won't interfere constructor's initial map. 1312 // Copy map so it won't interfere constructor's initial map.
1315 Object* new_map; 1313 Map* new_map;
1316 { MaybeObject* maybe_new_map = 1314 MaybeObject* maybe_new_map = old_map->Copy(DescriptorArray::MAY_BE_SHARED);
1317 old_map->CopyDropTransitions(DescriptorArray::MAY_BE_SHARED); 1315 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
1318 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
1319 }
1320 1316
1321 Map::cast(new_map)->set_is_access_check_needed(true); 1317 new_map->set_is_access_check_needed(true);
1322 object->set_map(Map::cast(new_map)); 1318 object->set_map(new_map);
1323 } 1319 }
1324 return isolate->heap()->undefined_value(); 1320 return isolate->heap()->undefined_value();
1325 } 1321 }
1326 1322
1327 1323
1328 static Failure* ThrowRedeclarationError(Isolate* isolate, 1324 static Failure* ThrowRedeclarationError(Isolate* isolate,
1329 const char* type, 1325 const char* type,
1330 Handle<String> name) { 1326 Handle<String> name) {
1331 HandleScope scope(isolate); 1327 HandleScope scope(isolate);
1332 Handle<Object> type_handle = 1328 Handle<Object> type_handle =
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 CONVERT_ARG_CHECKED(JSFunction, function, 0); 2161 CONVERT_ARG_CHECKED(JSFunction, function, 0);
2166 2162
2167 MaybeObject* maybe_name = 2163 MaybeObject* maybe_name =
2168 isolate->heap()->AllocateStringFromAscii(CStrVector("prototype")); 2164 isolate->heap()->AllocateStringFromAscii(CStrVector("prototype"));
2169 String* name; 2165 String* name;
2170 if (!maybe_name->To(&name)) return maybe_name; 2166 if (!maybe_name->To(&name)) return maybe_name;
2171 2167
2172 if (function->HasFastProperties()) { 2168 if (function->HasFastProperties()) {
2173 // Construct a new field descriptor with updated attributes. 2169 // Construct a new field descriptor with updated attributes.
2174 DescriptorArray* instance_desc = function->map()->instance_descriptors(); 2170 DescriptorArray* instance_desc = function->map()->instance_descriptors();
2171
2175 int index = instance_desc->Search(name); 2172 int index = instance_desc->Search(name);
2176 ASSERT(index != DescriptorArray::kNotFound); 2173 ASSERT(index != DescriptorArray::kNotFound);
2177 PropertyDetails details = instance_desc->GetDetails(index); 2174 PropertyDetails details = instance_desc->GetDetails(index);
2175
2178 CallbacksDescriptor new_desc(name, 2176 CallbacksDescriptor new_desc(name,
2179 instance_desc->GetValue(index), 2177 instance_desc->GetValue(index),
2180 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), 2178 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY),
2181 details.index()); 2179 details.index());
2182 // Construct a new field descriptors array containing the new descriptor. 2180
2183 DescriptorArray* new_descriptors;
2184 { MaybeObject* maybe_descriptors =
2185 instance_desc->CopyReplace(&new_desc, index);
2186 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
2187 }
2188 // Create a new map featuring the new field descriptors array. 2181 // Create a new map featuring the new field descriptors array.
2189 Map* new_map; 2182 Map* new_map;
2190 { MaybeObject* maybe_map = 2183 MaybeObject* maybe_map =
2191 function->map()->CopyReplaceDescriptors(new_descriptors); 2184 function->map()->CopyReplaceDescriptor(
2192 if (!maybe_map->To(&new_map)) return maybe_map; 2185 &new_desc, index, OMIT_TRANSITION);
2193 } 2186 if (!maybe_map->To(&new_map)) return maybe_map;
2187
2194 function->set_map(new_map); 2188 function->set_map(new_map);
2195 } else { // Dictionary properties. 2189 } else { // Dictionary properties.
2196 // Directly manipulate the property details. 2190 // Directly manipulate the property details.
2197 int entry = function->property_dictionary()->FindEntry(name); 2191 int entry = function->property_dictionary()->FindEntry(name);
2198 ASSERT(entry != StringDictionary::kNotFound); 2192 ASSERT(entry != StringDictionary::kNotFound);
2199 PropertyDetails details = function->property_dictionary()->DetailsAt(entry); 2193 PropertyDetails details = function->property_dictionary()->DetailsAt(entry);
2200 PropertyDetails new_details( 2194 PropertyDetails new_details(
2201 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), 2195 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY),
2202 details.type(), 2196 details.type(),
2203 details.index()); 2197 details.index());
(...skipping 5618 matching lines...) Expand 10 before | Expand all | Expand 10 after
7822 int parameter_count = callee->shared()->formal_parameter_count(); 7816 int parameter_count = callee->shared()->formal_parameter_count();
7823 if (argument_count > 0) { 7817 if (argument_count > 0) {
7824 if (parameter_count > 0) { 7818 if (parameter_count > 0) {
7825 int mapped_count = Min(argument_count, parameter_count); 7819 int mapped_count = Min(argument_count, parameter_count);
7826 Handle<FixedArray> parameter_map = 7820 Handle<FixedArray> parameter_map =
7827 isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED); 7821 isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED);
7828 parameter_map->set_map( 7822 parameter_map->set_map(
7829 isolate->heap()->non_strict_arguments_elements_map()); 7823 isolate->heap()->non_strict_arguments_elements_map());
7830 7824
7831 Handle<Map> old_map(result->map()); 7825 Handle<Map> old_map(result->map());
7832 Handle<Map> new_map = 7826 Handle<Map> new_map = isolate->factory()->CopyMap(old_map);
7833 isolate->factory()->CopyMapDropTransitions(old_map);
7834 new_map->set_elements_kind(NON_STRICT_ARGUMENTS_ELEMENTS); 7827 new_map->set_elements_kind(NON_STRICT_ARGUMENTS_ELEMENTS);
7835 7828
7836 result->set_map(*new_map); 7829 result->set_map(*new_map);
7837 result->set_elements(*parameter_map); 7830 result->set_elements(*parameter_map);
7838 7831
7839 // Store the context and the arguments array at the beginning of the 7832 // Store the context and the arguments array at the beginning of the
7840 // parameter map. 7833 // parameter map.
7841 Handle<Context> context(isolate->context()); 7834 Handle<Context> context(isolate->context());
7842 Handle<FixedArray> arguments = 7835 Handle<FixedArray> arguments =
7843 isolate->factory()->NewFixedArray(argument_count, NOT_TENURED); 7836 isolate->factory()->NewFixedArray(argument_count, NOT_TENURED);
(...skipping 5868 matching lines...) Expand 10 before | Expand all | Expand 10 after
13712 // Handle last resort GC and make sure to allow future allocations 13705 // Handle last resort GC and make sure to allow future allocations
13713 // to grow the heap without causing GCs (if possible). 13706 // to grow the heap without causing GCs (if possible).
13714 isolate->counters()->gc_last_resort_from_js()->Increment(); 13707 isolate->counters()->gc_last_resort_from_js()->Increment();
13715 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13708 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13716 "Runtime::PerformGC"); 13709 "Runtime::PerformGC");
13717 } 13710 }
13718 } 13711 }
13719 13712
13720 13713
13721 } } // namespace v8::internal 13714 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698