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

Side by Side Diff: src/heap.cc

Issue 15993016: Remove the optimized construct stub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 6 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/compiler.cc ('k') | src/heap-snapshot-generator.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 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 3359 matching lines...) Expand 10 before | Expand all | Expand 10 after
3370 share->set_scope_info(ScopeInfo::Empty(isolate_)); 3370 share->set_scope_info(ScopeInfo::Empty(isolate_));
3371 Code* construct_stub = 3371 Code* construct_stub =
3372 isolate_->builtins()->builtin(Builtins::kJSConstructStubGeneric); 3372 isolate_->builtins()->builtin(Builtins::kJSConstructStubGeneric);
3373 share->set_construct_stub(construct_stub); 3373 share->set_construct_stub(construct_stub);
3374 share->set_instance_class_name(Object_string()); 3374 share->set_instance_class_name(Object_string());
3375 share->set_function_data(undefined_value(), SKIP_WRITE_BARRIER); 3375 share->set_function_data(undefined_value(), SKIP_WRITE_BARRIER);
3376 share->set_script(undefined_value(), SKIP_WRITE_BARRIER); 3376 share->set_script(undefined_value(), SKIP_WRITE_BARRIER);
3377 share->set_debug_info(undefined_value(), SKIP_WRITE_BARRIER); 3377 share->set_debug_info(undefined_value(), SKIP_WRITE_BARRIER);
3378 share->set_inferred_name(empty_string(), SKIP_WRITE_BARRIER); 3378 share->set_inferred_name(empty_string(), SKIP_WRITE_BARRIER);
3379 share->set_initial_map(undefined_value(), SKIP_WRITE_BARRIER); 3379 share->set_initial_map(undefined_value(), SKIP_WRITE_BARRIER);
3380 share->set_this_property_assignments(undefined_value(), SKIP_WRITE_BARRIER);
3381 share->set_ast_node_count(0); 3380 share->set_ast_node_count(0);
3382 share->set_stress_deopt_counter(FLAG_deopt_every_n_times); 3381 share->set_stress_deopt_counter(FLAG_deopt_every_n_times);
3383 share->set_counters(0); 3382 share->set_counters(0);
3384 3383
3385 // Set integer fields (smi or int, depending on the architecture). 3384 // Set integer fields (smi or int, depending on the architecture).
3386 share->set_length(0); 3385 share->set_length(0);
3387 share->set_formal_parameter_count(0); 3386 share->set_formal_parameter_count(0);
3388 share->set_expected_nof_properties(0); 3387 share->set_expected_nof_properties(0);
3389 share->set_num_literals(0); 3388 share->set_num_literals(0);
3390 share->set_start_position_and_type(0); 3389 share->set_start_position_and_type(0);
3391 share->set_end_position(0); 3390 share->set_end_position(0);
3392 share->set_function_token_position(0); 3391 share->set_function_token_position(0);
3393 // All compiler hints default to false or 0. 3392 // All compiler hints default to false or 0.
3394 share->set_compiler_hints(0); 3393 share->set_compiler_hints(0);
3395 share->set_this_property_assignments_count(0);
3396 share->set_opt_count(0); 3394 share->set_opt_count(0);
3397 3395
3398 return share; 3396 return share;
3399 } 3397 }
3400 3398
3401 3399
3402 MaybeObject* Heap::AllocateJSMessageObject(String* type, 3400 MaybeObject* Heap::AllocateJSMessageObject(String* type,
3403 JSArray* arguments, 3401 JSArray* arguments,
3404 int start_position, 3402 int start_position,
3405 int end_position, 3403 int end_position,
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
4154 } 4152 }
4155 4153
4156 // Check the state of the object 4154 // Check the state of the object
4157 ASSERT(JSObject::cast(result)->HasFastProperties()); 4155 ASSERT(JSObject::cast(result)->HasFastProperties());
4158 ASSERT(JSObject::cast(result)->HasFastObjectElements()); 4156 ASSERT(JSObject::cast(result)->HasFastObjectElements());
4159 4157
4160 return result; 4158 return result;
4161 } 4159 }
4162 4160
4163 4161
4164 static bool HasDuplicates(DescriptorArray* descriptors) {
4165 int count = descriptors->number_of_descriptors();
4166 if (count > 1) {
4167 Name* prev_key = descriptors->GetKey(0);
4168 for (int i = 1; i != count; i++) {
4169 Name* current_key = descriptors->GetKey(i);
4170 if (prev_key == current_key) return true;
4171 prev_key = current_key;
4172 }
4173 }
4174 return false;
4175 }
4176
4177
4178 MaybeObject* Heap::AllocateInitialMap(JSFunction* fun) { 4162 MaybeObject* Heap::AllocateInitialMap(JSFunction* fun) {
4179 ASSERT(!fun->has_initial_map()); 4163 ASSERT(!fun->has_initial_map());
4180 4164
4181 // First create a new map with the size and number of in-object properties 4165 // First create a new map with the size and number of in-object properties
4182 // suggested by the function. 4166 // suggested by the function.
4183 InstanceType instance_type; 4167 InstanceType instance_type;
4184 int instance_size; 4168 int instance_size;
4185 int in_object_properties; 4169 int in_object_properties;
4186 if (fun->shared()->is_generator()) { 4170 if (fun->shared()->is_generator()) {
4187 instance_type = JS_GENERATOR_OBJECT_TYPE; 4171 instance_type = JS_GENERATOR_OBJECT_TYPE;
(...skipping 14 matching lines...) Expand all
4202 prototype = fun->instance_prototype(); 4186 prototype = fun->instance_prototype();
4203 } else { 4187 } else {
4204 MaybeObject* maybe_prototype = AllocateFunctionPrototype(fun); 4188 MaybeObject* maybe_prototype = AllocateFunctionPrototype(fun);
4205 if (!maybe_prototype->To(&prototype)) return maybe_prototype; 4189 if (!maybe_prototype->To(&prototype)) return maybe_prototype;
4206 } 4190 }
4207 map->set_inobject_properties(in_object_properties); 4191 map->set_inobject_properties(in_object_properties);
4208 map->set_unused_property_fields(in_object_properties); 4192 map->set_unused_property_fields(in_object_properties);
4209 map->set_prototype(prototype); 4193 map->set_prototype(prototype);
4210 ASSERT(map->has_fast_object_elements()); 4194 ASSERT(map->has_fast_object_elements());
4211 4195
4212 // If the function has only simple this property assignments add
4213 // field descriptors for these to the initial map as the object
4214 // cannot be constructed without having these properties. Guard by
4215 // the inline_new flag so we only change the map if we generate a
4216 // specialized construct stub.
4217 ASSERT(in_object_properties <= Map::kMaxPreAllocatedPropertyFields);
4218 if (!fun->shared()->is_generator() &&
4219 fun->shared()->CanGenerateInlineConstructor(prototype)) {
4220 int count = fun->shared()->this_property_assignments_count();
4221 if (count > in_object_properties) {
4222 // Inline constructor can only handle inobject properties.
4223 fun->shared()->ForbidInlineConstructor();
4224 } else {
4225 DescriptorArray* descriptors;
4226 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(count);
4227 if (!maybe_descriptors->To(&descriptors)) return maybe_descriptors;
4228
4229 DescriptorArray::WhitenessWitness witness(descriptors);
4230 for (int i = 0; i < count; i++) {
4231 String* name = fun->shared()->GetThisPropertyAssignmentName(i);
4232 ASSERT(name->IsInternalizedString());
4233 // TODO(verwaest): Since we cannot update the boilerplate's map yet,
4234 // initialize to the worst case.
4235 FieldDescriptor field(name, i, NONE, Representation::Tagged());
4236 descriptors->Set(i, &field, witness);
4237 }
4238 descriptors->Sort();
4239
4240 // The descriptors may contain duplicates because the compiler does not
4241 // guarantee the uniqueness of property names (it would have required
4242 // quadratic time). Once the descriptors are sorted we can check for
4243 // duplicates in linear time.
4244 if (HasDuplicates(descriptors)) {
4245 fun->shared()->ForbidInlineConstructor();
4246 } else {
4247 map->InitializeDescriptors(descriptors);
4248 map->set_pre_allocated_property_fields(count);
4249 map->set_unused_property_fields(in_object_properties - count);
4250 }
4251 }
4252 }
4253
4254 if (!fun->shared()->is_generator()) { 4196 if (!fun->shared()->is_generator()) {
4255 fun->shared()->StartInobjectSlackTracking(map); 4197 fun->shared()->StartInobjectSlackTracking(map);
4256 } 4198 }
4257 4199
4258 return map; 4200 return map;
4259 } 4201 }
4260 4202
4261 4203
4262 void Heap::InitializeJSObjectFromMap(JSObject* obj, 4204 void Heap::InitializeJSObjectFromMap(JSObject* obj,
4263 FixedArray* properties, 4205 FixedArray* properties,
(...skipping 3679 matching lines...) Expand 10 before | Expand all | Expand 10 after
7943 if (FLAG_parallel_recompilation) { 7885 if (FLAG_parallel_recompilation) {
7944 heap_->relocation_mutex_->Lock(); 7886 heap_->relocation_mutex_->Lock();
7945 #ifdef DEBUG 7887 #ifdef DEBUG
7946 heap_->relocation_mutex_locked_by_optimizer_thread_ = 7888 heap_->relocation_mutex_locked_by_optimizer_thread_ =
7947 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); 7889 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread();
7948 #endif // DEBUG 7890 #endif // DEBUG
7949 } 7891 }
7950 } 7892 }
7951 7893
7952 } } // namespace v8::internal 7894 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/heap-snapshot-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698