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

Side by Side Diff: src/factory.cc

Issue 10916336: Preallocate space in descriptor arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: u Created 8 years, 3 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/factory.h ('k') | src/objects.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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 106
107 Handle<ObjectHashTable> Factory::NewObjectHashTable(int at_least_space_for) { 107 Handle<ObjectHashTable> Factory::NewObjectHashTable(int at_least_space_for) {
108 ASSERT(0 <= at_least_space_for); 108 ASSERT(0 <= at_least_space_for);
109 CALL_HEAP_FUNCTION(isolate(), 109 CALL_HEAP_FUNCTION(isolate(),
110 ObjectHashTable::Allocate(at_least_space_for), 110 ObjectHashTable::Allocate(at_least_space_for),
111 ObjectHashTable); 111 ObjectHashTable);
112 } 112 }
113 113
114 114
115 Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors) { 115 Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors,
116 int slack) {
116 ASSERT(0 <= number_of_descriptors); 117 ASSERT(0 <= number_of_descriptors);
117 CALL_HEAP_FUNCTION(isolate(), 118 CALL_HEAP_FUNCTION(isolate(),
118 DescriptorArray::Allocate(number_of_descriptors), 119 DescriptorArray::Allocate(number_of_descriptors, slack),
119 DescriptorArray); 120 DescriptorArray);
120 } 121 }
121 122
122 123
123 Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData( 124 Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData(
124 int deopt_entry_count, 125 int deopt_entry_count,
125 PretenureFlag pretenure) { 126 PretenureFlag pretenure) {
126 ASSERT(deopt_entry_count > 0); 127 ASSERT(deopt_entry_count > 0);
127 CALL_HEAP_FUNCTION(isolate(), 128 CALL_HEAP_FUNCTION(isolate(),
128 DeoptimizationInputData::Allocate(deopt_entry_count, 129 DeoptimizationInputData::Allocate(deopt_entry_count,
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 // Set instance call-as-function information in the map. 1278 // Set instance call-as-function information in the map.
1278 if (!obj->instance_call_handler()->IsUndefined()) { 1279 if (!obj->instance_call_handler()->IsUndefined()) {
1279 map->set_has_instance_call_handler(); 1280 map->set_has_instance_call_handler();
1280 } 1281 }
1281 1282
1282 result->shared()->set_function_data(*obj); 1283 result->shared()->set_function_data(*obj);
1283 result->shared()->set_construct_stub(*construct_stub); 1284 result->shared()->set_construct_stub(*construct_stub);
1284 result->shared()->DontAdaptArguments(); 1285 result->shared()->DontAdaptArguments();
1285 1286
1286 // Recursively copy parent templates' accessors, 'data' may be modified. 1287 // Recursively copy parent templates' accessors, 'data' may be modified.
1288 int max_number_of_additional_properties = 0;
1289 FunctionTemplateInfo* info = *obj;
1290 while (true) {
1291 Object* props = info->property_accessors();
1292 if (!props->IsUndefined()) {
1293 Handle<Object> props_handle(props);
1294 NeanderArray props_array(props_handle);
1295 max_number_of_additional_properties += props_array.length();
1296 }
1297 Object* parent = info->parent_template();
1298 if (parent->IsUndefined()) break;
1299 info = FunctionTemplateInfo::cast(parent);
1300 }
1301
1302 Map::EnsureDescriptorSlack(map, max_number_of_additional_properties);
1303
1287 while (true) { 1304 while (true) {
1288 Handle<Object> props = Handle<Object>(obj->property_accessors()); 1305 Handle<Object> props = Handle<Object>(obj->property_accessors());
1289 if (!props->IsUndefined()) { 1306 if (!props->IsUndefined()) {
1290 Map::CopyAppendCallbackDescriptors(map, props); 1307 Map::AppendCallbackDescriptors(map, props);
1291 } 1308 }
1292 Handle<Object> parent = Handle<Object>(obj->parent_template()); 1309 Handle<Object> parent = Handle<Object>(obj->parent_template());
1293 if (parent->IsUndefined()) break; 1310 if (parent->IsUndefined()) break;
1294 obj = Handle<FunctionTemplateInfo>::cast(parent); 1311 obj = Handle<FunctionTemplateInfo>::cast(parent);
1295 } 1312 }
1296 1313
1297 ASSERT(result->shared()->IsApiFunction()); 1314 ASSERT(result->shared()->IsApiFunction());
1298 return result; 1315 return result;
1299 } 1316 }
1300 1317
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 1426
1410 1427
1411 Handle<Object> Factory::ToBoolean(bool value) { 1428 Handle<Object> Factory::ToBoolean(bool value) {
1412 return Handle<Object>(value 1429 return Handle<Object>(value
1413 ? isolate()->heap()->true_value() 1430 ? isolate()->heap()->true_value()
1414 : isolate()->heap()->false_value()); 1431 : isolate()->heap()->false_value());
1415 } 1432 }
1416 1433
1417 1434
1418 } } // namespace v8::internal 1435 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698