OLD | NEW |
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 8198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8209 // Checks whether allocation using the given constructor can be inlined. | 8209 // Checks whether allocation using the given constructor can be inlined. |
8210 static bool IsAllocationInlineable(Handle<JSFunction> constructor) { | 8210 static bool IsAllocationInlineable(Handle<JSFunction> constructor) { |
8211 return constructor->has_initial_map() && | 8211 return constructor->has_initial_map() && |
8212 constructor->initial_map()->instance_type() == JS_OBJECT_TYPE && | 8212 constructor->initial_map()->instance_type() == JS_OBJECT_TYPE && |
8213 constructor->initial_map()->instance_size() < HAllocate::kMaxInlineSize && | 8213 constructor->initial_map()->instance_size() < HAllocate::kMaxInlineSize && |
8214 constructor->initial_map()->InitialPropertiesLength() == 0; | 8214 constructor->initial_map()->InitialPropertiesLength() == 0; |
8215 } | 8215 } |
8216 | 8216 |
8217 | 8217 |
8218 bool HOptimizedGraphBuilder::IsCallNewArrayInlineable(CallNew* expr) { | 8218 bool HOptimizedGraphBuilder::IsCallNewArrayInlineable(CallNew* expr) { |
8219 bool inline_ok = false; | 8219 Handle<AllocationSite> site = expr->allocation_site(); |
| 8220 if (site.is_null()) return false; |
| 8221 |
8220 Handle<JSFunction> caller = current_info()->closure(); | 8222 Handle<JSFunction> caller = current_info()->closure(); |
8221 Handle<JSFunction> target(isolate()->global_context()->array_function(), | 8223 Handle<JSFunction> target(isolate()->native_context()->array_function(), |
8222 isolate()); | 8224 isolate()); |
8223 int argument_count = expr->arguments()->length(); | 8225 int argument_count = expr->arguments()->length(); |
8224 // We should have the function plus array arguments on the environment stack. | 8226 // We should have the function plus array arguments on the environment stack. |
8225 ASSERT(environment()->length() >= (argument_count + 1)); | 8227 ASSERT(environment()->length() >= (argument_count + 1)); |
8226 Handle<AllocationSite> site = expr->allocation_site(); | |
8227 ASSERT(!site.is_null()); | |
8228 | 8228 |
| 8229 bool inline_ok = false; |
8229 if (site->CanInlineCall()) { | 8230 if (site->CanInlineCall()) { |
8230 // We also want to avoid inlining in certain 1 argument scenarios. | 8231 // We also want to avoid inlining in certain 1 argument scenarios. |
8231 if (argument_count == 1) { | 8232 if (argument_count == 1) { |
8232 HValue* argument = Top(); | 8233 HValue* argument = Top(); |
8233 if (argument->IsConstant()) { | 8234 if (argument->IsConstant()) { |
8234 // Do not inline if the constant length argument is not a smi or | 8235 // Do not inline if the constant length argument is not a smi or |
8235 // outside the valid range for a fast array. | 8236 // outside the valid range for a fast array. |
8236 HConstant* constant_argument = HConstant::cast(argument); | 8237 HConstant* constant_argument = HConstant::cast(argument); |
8237 if (constant_argument->HasSmiValue()) { | 8238 if (constant_argument->HasSmiValue()) { |
8238 int value = constant_argument->Integer32Value(); | 8239 int value = constant_argument->Integer32Value(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8358 receiver->DeleteAndReplaceWith(NULL); | 8359 receiver->DeleteAndReplaceWith(NULL); |
8359 check->DeleteAndReplaceWith(NULL); | 8360 check->DeleteAndReplaceWith(NULL); |
8360 environment()->SetExpressionStackAt(receiver_index, function); | 8361 environment()->SetExpressionStackAt(receiver_index, function); |
8361 HInstruction* call = | 8362 HInstruction* call = |
8362 PreProcessCall(New<HCallNew>(function, argument_count)); | 8363 PreProcessCall(New<HCallNew>(function, argument_count)); |
8363 return ast_context()->ReturnInstruction(call, expr->id()); | 8364 return ast_context()->ReturnInstruction(call, expr->id()); |
8364 } else { | 8365 } else { |
8365 // The constructor function is both an operand to the instruction and an | 8366 // The constructor function is both an operand to the instruction and an |
8366 // argument to the construct call. | 8367 // argument to the construct call. |
8367 Handle<JSFunction> array_function( | 8368 Handle<JSFunction> array_function( |
8368 isolate()->global_context()->array_function(), isolate()); | 8369 isolate()->native_context()->array_function(), isolate()); |
8369 bool use_call_new_array = expr->target().is_identical_to(array_function); | 8370 bool use_call_new_array = expr->target().is_identical_to(array_function); |
8370 if (use_call_new_array && IsCallNewArrayInlineable(expr)) { | 8371 if (use_call_new_array && IsCallNewArrayInlineable(expr)) { |
8371 // Verify we are still calling the array function for our native context. | 8372 // Verify we are still calling the array function for our native context. |
8372 Add<HCheckValue>(function, array_function); | 8373 Add<HCheckValue>(function, array_function); |
8373 BuildInlinedCallNewArray(expr); | 8374 BuildInlinedCallNewArray(expr); |
8374 return; | 8375 return; |
8375 } | 8376 } |
8376 | 8377 |
8377 HBinaryCall* call; | 8378 HBinaryCall* call; |
8378 if (use_call_new_array) { | 8379 if (use_call_new_array) { |
(...skipping 2910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11289 if (ShouldProduceTraceOutput()) { | 11290 if (ShouldProduceTraceOutput()) { |
11290 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11291 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11291 } | 11292 } |
11292 | 11293 |
11293 #ifdef DEBUG | 11294 #ifdef DEBUG |
11294 graph_->Verify(false); // No full verify. | 11295 graph_->Verify(false); // No full verify. |
11295 #endif | 11296 #endif |
11296 } | 11297 } |
11297 | 11298 |
11298 } } // namespace v8::internal | 11299 } } // namespace v8::internal |
OLD | NEW |