OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 3413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3424 depends_on_empty_array_proto_elements_(false), | 3424 depends_on_empty_array_proto_elements_(false), |
3425 type_change_checksum_(0), | 3425 type_change_checksum_(0), |
3426 maximum_environment_size_(0), | 3426 maximum_environment_size_(0), |
3427 no_side_effects_scope_count_(0), | 3427 no_side_effects_scope_count_(0), |
3428 disallow_adding_new_values_(false), | 3428 disallow_adding_new_values_(false), |
3429 next_inline_id_(0), | 3429 next_inline_id_(0), |
3430 inlined_functions_(5, info->zone()) { | 3430 inlined_functions_(5, info->zone()) { |
3431 if (info->IsStub()) { | 3431 if (info->IsStub()) { |
3432 HydrogenCodeStub* stub = info->code_stub(); | 3432 HydrogenCodeStub* stub = info->code_stub(); |
3433 CodeStubInterfaceDescriptor* descriptor = stub->GetInterfaceDescriptor(); | 3433 CodeStubInterfaceDescriptor* descriptor = stub->GetInterfaceDescriptor(); |
| 3434 // The descriptor environment length includes a context register, which |
| 3435 // we handle separately, so subtract one. |
| 3436 ASSERT(descriptor->GetEnvironmentLength() > 0); |
3434 start_environment_ = | 3437 start_environment_ = |
3435 new(zone_) HEnvironment(zone_, descriptor->environment_length()); | 3438 new(zone_) HEnvironment(zone_, descriptor->GetEnvironmentLength() - 1); |
3436 } else { | 3439 } else { |
3437 TraceInlinedFunction(info->shared_info(), HSourcePosition::Unknown()); | 3440 TraceInlinedFunction(info->shared_info(), HSourcePosition::Unknown()); |
3438 start_environment_ = | 3441 start_environment_ = |
3439 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); | 3442 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); |
3440 } | 3443 } |
3441 start_environment_->set_ast_id(BailoutId::FunctionEntry()); | 3444 start_environment_->set_ast_id(BailoutId::FunctionEntry()); |
3442 entry_block_ = CreateBasicBlock(); | 3445 entry_block_ = CreateBasicBlock(); |
3443 entry_block_->SetInitialEnvironment(start_environment_); | 3446 entry_block_->SetInitialEnvironment(start_environment_); |
3444 } | 3447 } |
3445 | 3448 |
(...skipping 3890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7336 | 7339 |
7337 | 7340 |
7338 HInstruction* HOptimizedGraphBuilder::NewArgumentAdaptorCall( | 7341 HInstruction* HOptimizedGraphBuilder::NewArgumentAdaptorCall( |
7339 HValue* fun, HValue* context, | 7342 HValue* fun, HValue* context, |
7340 int argument_count, HValue* expected_param_count) { | 7343 int argument_count, HValue* expected_param_count) { |
7341 CallInterfaceDescriptor* descriptor = | 7344 CallInterfaceDescriptor* descriptor = |
7342 isolate()->call_descriptor(Isolate::ArgumentAdaptorCall); | 7345 isolate()->call_descriptor(Isolate::ArgumentAdaptorCall); |
7343 | 7346 |
7344 HValue* arity = Add<HConstant>(argument_count - 1); | 7347 HValue* arity = Add<HConstant>(argument_count - 1); |
7345 | 7348 |
7346 HValue* op_vals[] = { fun, context, arity, expected_param_count }; | 7349 HValue* op_vals[] = { context, fun, arity, expected_param_count }; |
7347 | 7350 |
7348 Handle<Code> adaptor = | 7351 Handle<Code> adaptor = |
7349 isolate()->builtins()->ArgumentsAdaptorTrampoline(); | 7352 isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
7350 HConstant* adaptor_value = Add<HConstant>(adaptor); | 7353 HConstant* adaptor_value = Add<HConstant>(adaptor); |
7351 | 7354 |
7352 return New<HCallWithDescriptor>( | 7355 return New<HCallWithDescriptor>( |
7353 adaptor_value, argument_count, descriptor, | 7356 adaptor_value, argument_count, descriptor, |
7354 Vector<HValue*>(op_vals, descriptor->environment_length())); | 7357 Vector<HValue*>(op_vals, descriptor->GetEnvironmentLength())); |
7355 } | 7358 } |
7356 | 7359 |
7357 | 7360 |
7358 HInstruction* HOptimizedGraphBuilder::BuildCallConstantFunction( | 7361 HInstruction* HOptimizedGraphBuilder::BuildCallConstantFunction( |
7359 Handle<JSFunction> jsfun, int argument_count) { | 7362 Handle<JSFunction> jsfun, int argument_count) { |
7360 HValue* target = Add<HConstant>(jsfun); | 7363 HValue* target = Add<HConstant>(jsfun); |
7361 // For constant functions, we try to avoid calling the | 7364 // For constant functions, we try to avoid calling the |
7362 // argument adaptor and instead call the function directly | 7365 // argument adaptor and instead call the function directly |
7363 int formal_parameter_count = jsfun->shared()->formal_parameter_count(); | 7366 int formal_parameter_count = jsfun->shared()->formal_parameter_count(); |
7364 bool dont_adapt_arguments = | 7367 bool dont_adapt_arguments = |
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8574 Handle<Object> call_data_obj(api_call_info->data(), isolate()); | 8577 Handle<Object> call_data_obj(api_call_info->data(), isolate()); |
8575 bool call_data_is_undefined = call_data_obj->IsUndefined(); | 8578 bool call_data_is_undefined = call_data_obj->IsUndefined(); |
8576 HValue* call_data = Add<HConstant>(call_data_obj); | 8579 HValue* call_data = Add<HConstant>(call_data_obj); |
8577 ApiFunction fun(v8::ToCData<Address>(api_call_info->callback())); | 8580 ApiFunction fun(v8::ToCData<Address>(api_call_info->callback())); |
8578 ExternalReference ref = ExternalReference(&fun, | 8581 ExternalReference ref = ExternalReference(&fun, |
8579 ExternalReference::DIRECT_API_CALL, | 8582 ExternalReference::DIRECT_API_CALL, |
8580 isolate()); | 8583 isolate()); |
8581 HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); | 8584 HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); |
8582 | 8585 |
8583 HValue* op_vals[] = { | 8586 HValue* op_vals[] = { |
| 8587 context(), |
8584 Add<HConstant>(function), | 8588 Add<HConstant>(function), |
8585 call_data, | 8589 call_data, |
8586 holder, | 8590 holder, |
8587 api_function_address, | 8591 api_function_address |
8588 context() | |
8589 }; | 8592 }; |
8590 | 8593 |
8591 CallInterfaceDescriptor* descriptor = | 8594 CallInterfaceDescriptor* descriptor = |
8592 isolate()->call_descriptor(Isolate::ApiFunctionCall); | 8595 isolate()->call_descriptor(Isolate::ApiFunctionCall); |
8593 | 8596 |
8594 CallApiFunctionStub stub(isolate(), is_store, call_data_is_undefined, argc); | 8597 CallApiFunctionStub stub(isolate(), is_store, call_data_is_undefined, argc); |
8595 Handle<Code> code = stub.GetCode(); | 8598 Handle<Code> code = stub.GetCode(); |
8596 HConstant* code_value = Add<HConstant>(code); | 8599 HConstant* code_value = Add<HConstant>(code); |
8597 | 8600 |
8598 ASSERT((sizeof(op_vals) / kPointerSize) == | 8601 ASSERT((sizeof(op_vals) / kPointerSize) == |
8599 descriptor->environment_length()); | 8602 descriptor->GetEnvironmentLength()); |
8600 | 8603 |
8601 HInstruction* call = New<HCallWithDescriptor>( | 8604 HInstruction* call = New<HCallWithDescriptor>( |
8602 code_value, argc + 1, descriptor, | 8605 code_value, argc + 1, descriptor, |
8603 Vector<HValue*>(op_vals, descriptor->environment_length())); | 8606 Vector<HValue*>(op_vals, descriptor->GetEnvironmentLength())); |
8604 | 8607 |
8605 if (drop_extra) Drop(1); // Drop function. | 8608 if (drop_extra) Drop(1); // Drop function. |
8606 ast_context()->ReturnInstruction(call, ast_id); | 8609 ast_context()->ReturnInstruction(call, ast_id); |
8607 return true; | 8610 return true; |
8608 } | 8611 } |
8609 | 8612 |
8610 | 8613 |
8611 bool HOptimizedGraphBuilder::TryCallApply(Call* expr) { | 8614 bool HOptimizedGraphBuilder::TryCallApply(Call* expr) { |
8612 ASSERT(expr->expression()->IsProperty()); | 8615 ASSERT(expr->expression()->IsProperty()); |
8613 | 8616 |
(...skipping 3810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12424 if (ShouldProduceTraceOutput()) { | 12427 if (ShouldProduceTraceOutput()) { |
12425 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12428 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12426 } | 12429 } |
12427 | 12430 |
12428 #ifdef DEBUG | 12431 #ifdef DEBUG |
12429 graph_->Verify(false); // No full verify. | 12432 graph_->Verify(false); // No full verify. |
12430 #endif | 12433 #endif |
12431 } | 12434 } |
12432 | 12435 |
12433 } } // namespace v8::internal | 12436 } } // namespace v8::internal |
OLD | NEW |