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/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
(...skipping 3474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3485 use_optimistic_licm_(false), | 3485 use_optimistic_licm_(false), |
3486 depends_on_empty_array_proto_elements_(false), | 3486 depends_on_empty_array_proto_elements_(false), |
3487 depends_on_string_length_overflow_(false), | 3487 depends_on_string_length_overflow_(false), |
3488 type_change_checksum_(0), | 3488 type_change_checksum_(0), |
3489 maximum_environment_size_(0), | 3489 maximum_environment_size_(0), |
3490 no_side_effects_scope_count_(0), | 3490 no_side_effects_scope_count_(0), |
3491 disallow_adding_new_values_(false), | 3491 disallow_adding_new_values_(false), |
3492 inlined_function_infos_(info->zone()) { | 3492 inlined_function_infos_(info->zone()) { |
3493 if (info->IsStub()) { | 3493 if (info->IsStub()) { |
3494 // For stubs, explicitly add the context to the environment. | 3494 // For stubs, explicitly add the context to the environment. |
3495 start_environment_ = new (zone_) | 3495 start_environment_ = |
3496 HEnvironment(zone_, descriptor.GetRegisterParameterCount() + 1); | 3496 new (zone_) HEnvironment(zone_, descriptor.GetParameterCount() + 1); |
3497 } else { | 3497 } else { |
3498 start_environment_ = | 3498 start_environment_ = |
3499 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); | 3499 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); |
3500 } | 3500 } |
3501 start_environment_->set_ast_id(BailoutId::FunctionContext()); | 3501 start_environment_->set_ast_id(BailoutId::FunctionContext()); |
3502 entry_block_ = CreateBasicBlock(); | 3502 entry_block_ = CreateBasicBlock(); |
3503 entry_block_->SetInitialEnvironment(start_environment_); | 3503 entry_block_->SetInitialEnvironment(start_environment_); |
3504 } | 3504 } |
3505 | 3505 |
3506 | 3506 |
(...skipping 5716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9223 Handle<Object> call_data_obj(api_call_info->data(), isolate()); | 9223 Handle<Object> call_data_obj(api_call_info->data(), isolate()); |
9224 bool call_data_undefined = call_data_obj->IsUndefined(isolate()); | 9224 bool call_data_undefined = call_data_obj->IsUndefined(isolate()); |
9225 HValue* call_data = Add<HConstant>(call_data_obj); | 9225 HValue* call_data = Add<HConstant>(call_data_obj); |
9226 ApiFunction fun(v8::ToCData<Address>(api_call_info->callback())); | 9226 ApiFunction fun(v8::ToCData<Address>(api_call_info->callback())); |
9227 ExternalReference ref = ExternalReference(&fun, | 9227 ExternalReference ref = ExternalReference(&fun, |
9228 ExternalReference::DIRECT_API_CALL, | 9228 ExternalReference::DIRECT_API_CALL, |
9229 isolate()); | 9229 isolate()); |
9230 HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); | 9230 HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); |
9231 | 9231 |
9232 HValue* op_vals[] = {context(), Add<HConstant>(function), call_data, holder, | 9232 HValue* op_vals[] = {context(), Add<HConstant>(function), call_data, holder, |
9233 api_function_address, nullptr}; | 9233 api_function_address}; |
9234 | 9234 |
9235 HInstruction* call = nullptr; | 9235 HInstruction* call = nullptr; |
9236 CHECK(argc <= CallApiCallbackStub::kArgMax); | 9236 CHECK(argc <= CallApiCallbackStub::kArgMax); |
9237 if (!is_function) { | 9237 if (!is_function) { |
9238 CallApiCallbackStub stub(isolate(), is_store, call_data_undefined, | 9238 CallApiCallbackStub stub(isolate(), is_store, call_data_undefined, |
9239 !optimization.is_constant_call()); | 9239 !optimization.is_constant_call()); |
9240 Handle<Code> code = stub.GetCode(); | 9240 Handle<Code> code = stub.GetCode(); |
9241 HConstant* code_value = Add<HConstant>(code); | 9241 HConstant* code_value = Add<HConstant>(code); |
9242 call = New<HCallWithDescriptor>( | 9242 call = New<HCallWithDescriptor>( |
9243 code_value, argc + 1, stub.GetCallInterfaceDescriptor(), | 9243 code_value, argc + 1, stub.GetCallInterfaceDescriptor(), |
9244 Vector<HValue*>(op_vals, arraysize(op_vals) - 1), | 9244 Vector<HValue*>(op_vals, arraysize(op_vals)), syntactic_tail_call_mode); |
9245 syntactic_tail_call_mode); | |
9246 } else { | 9245 } else { |
9247 CallApiCallbackStub stub(isolate(), argc, call_data_undefined, false); | 9246 CallApiCallbackStub stub(isolate(), argc, call_data_undefined, false); |
9248 Handle<Code> code = stub.GetCode(); | 9247 Handle<Code> code = stub.GetCode(); |
9249 HConstant* code_value = Add<HConstant>(code); | 9248 HConstant* code_value = Add<HConstant>(code); |
9250 call = New<HCallWithDescriptor>( | 9249 call = New<HCallWithDescriptor>( |
9251 code_value, argc + 1, stub.GetCallInterfaceDescriptor(), | 9250 code_value, argc + 1, stub.GetCallInterfaceDescriptor(), |
9252 Vector<HValue*>(op_vals, arraysize(op_vals) - 1), | 9251 Vector<HValue*>(op_vals, arraysize(op_vals)), syntactic_tail_call_mode); |
9253 syntactic_tail_call_mode); | |
9254 Drop(1); // Drop function. | 9252 Drop(1); // Drop function. |
9255 } | 9253 } |
9256 | 9254 |
9257 ast_context()->ReturnInstruction(call, ast_id); | 9255 ast_context()->ReturnInstruction(call, ast_id); |
9258 return true; | 9256 return true; |
9259 } | 9257 } |
9260 | 9258 |
9261 | 9259 |
9262 void HOptimizedGraphBuilder::HandleIndirectCall(Call* expr, HValue* function, | 9260 void HOptimizedGraphBuilder::HandleIndirectCall(Call* expr, HValue* function, |
9263 int arguments_count) { | 9261 int arguments_count) { |
(...skipping 3047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12311 HValue* char_code = Pop(); | 12309 HValue* char_code = Pop(); |
12312 HInstruction* result = NewUncasted<HStringCharFromCode>(char_code); | 12310 HInstruction* result = NewUncasted<HStringCharFromCode>(char_code); |
12313 return ast_context()->ReturnInstruction(result, call->id()); | 12311 return ast_context()->ReturnInstruction(result, call->id()); |
12314 } | 12312 } |
12315 | 12313 |
12316 | 12314 |
12317 // Fast support for SubString. | 12315 // Fast support for SubString. |
12318 void HOptimizedGraphBuilder::GenerateSubString(CallRuntime* call) { | 12316 void HOptimizedGraphBuilder::GenerateSubString(CallRuntime* call) { |
12319 DCHECK_EQ(3, call->arguments()->length()); | 12317 DCHECK_EQ(3, call->arguments()->length()); |
12320 CHECK_ALIVE(VisitExpressions(call->arguments())); | 12318 CHECK_ALIVE(VisitExpressions(call->arguments())); |
12321 PushArgumentsFromEnvironment(call->arguments()->length()); | |
12322 Callable callable = CodeFactory::SubString(isolate()); | 12319 Callable callable = CodeFactory::SubString(isolate()); |
12323 HValue* stub = Add<HConstant>(callable.code()); | 12320 HValue* stub = Add<HConstant>(callable.code()); |
12324 HValue* values[] = {context()}; | 12321 HValue* to = Pop(); |
12325 HInstruction* result = | 12322 HValue* from = Pop(); |
12326 New<HCallWithDescriptor>(stub, call->arguments()->length(), | 12323 HValue* string = Pop(); |
12327 callable.descriptor(), ArrayVector(values)); | 12324 HValue* values[] = {context(), string, from, to}; |
| 12325 HInstruction* result = New<HCallWithDescriptor>( |
| 12326 stub, 0, callable.descriptor(), ArrayVector(values)); |
12328 result->set_type(HType::String()); | 12327 result->set_type(HType::String()); |
12329 return ast_context()->ReturnInstruction(result, call->id()); | 12328 return ast_context()->ReturnInstruction(result, call->id()); |
12330 } | 12329 } |
12331 | 12330 |
12332 // Support for direct creation of new objects. | 12331 // Support for direct creation of new objects. |
12333 void HOptimizedGraphBuilder::GenerateNewObject(CallRuntime* call) { | 12332 void HOptimizedGraphBuilder::GenerateNewObject(CallRuntime* call) { |
12334 DCHECK_EQ(2, call->arguments()->length()); | 12333 DCHECK_EQ(2, call->arguments()->length()); |
12335 CHECK_ALIVE(VisitExpressions(call->arguments())); | 12334 CHECK_ALIVE(VisitExpressions(call->arguments())); |
12336 FastNewObjectStub stub(isolate()); | 12335 FastNewObjectStub stub(isolate()); |
12337 FastNewObjectDescriptor descriptor(isolate()); | 12336 FastNewObjectDescriptor descriptor(isolate()); |
12338 HValue* values[] = {context(), Pop(), Pop()}; | 12337 HValue* values[] = {context(), Pop(), Pop()}; |
12339 HConstant* stub_value = Add<HConstant>(stub.GetCode()); | 12338 HConstant* stub_value = Add<HConstant>(stub.GetCode()); |
12340 HInstruction* result = | 12339 HInstruction* result = |
12341 New<HCallWithDescriptor>(stub_value, 0, descriptor, ArrayVector(values)); | 12340 New<HCallWithDescriptor>(stub_value, 0, descriptor, ArrayVector(values)); |
12342 return ast_context()->ReturnInstruction(result, call->id()); | 12341 return ast_context()->ReturnInstruction(result, call->id()); |
12343 } | 12342 } |
12344 | 12343 |
12345 // Support for direct calls from JavaScript to native RegExp code. | 12344 // Support for direct calls from JavaScript to native RegExp code. |
12346 void HOptimizedGraphBuilder::GenerateRegExpExec(CallRuntime* call) { | 12345 void HOptimizedGraphBuilder::GenerateRegExpExec(CallRuntime* call) { |
12347 DCHECK_EQ(4, call->arguments()->length()); | 12346 DCHECK_EQ(4, call->arguments()->length()); |
12348 CHECK_ALIVE(VisitExpressions(call->arguments())); | 12347 CHECK_ALIVE(VisitExpressions(call->arguments())); |
12349 PushArgumentsFromEnvironment(call->arguments()->length()); | |
12350 Callable callable = CodeFactory::RegExpExec(isolate()); | 12348 Callable callable = CodeFactory::RegExpExec(isolate()); |
| 12349 HValue* last_match_info = Pop(); |
| 12350 HValue* index = Pop(); |
| 12351 HValue* subject = Pop(); |
| 12352 HValue* regexp_object = Pop(); |
12351 HValue* stub = Add<HConstant>(callable.code()); | 12353 HValue* stub = Add<HConstant>(callable.code()); |
12352 HValue* values[] = {context()}; | 12354 HValue* values[] = {context(), regexp_object, subject, index, |
12353 HInstruction* result = | 12355 last_match_info}; |
12354 New<HCallWithDescriptor>(stub, call->arguments()->length(), | 12356 HInstruction* result = New<HCallWithDescriptor>( |
12355 callable.descriptor(), ArrayVector(values)); | 12357 stub, 0, callable.descriptor(), ArrayVector(values)); |
12356 return ast_context()->ReturnInstruction(result, call->id()); | 12358 return ast_context()->ReturnInstruction(result, call->id()); |
12357 } | 12359 } |
12358 | 12360 |
12359 | 12361 |
12360 void HOptimizedGraphBuilder::GenerateRegExpFlags(CallRuntime* call) { | 12362 void HOptimizedGraphBuilder::GenerateRegExpFlags(CallRuntime* call) { |
12361 DCHECK_EQ(1, call->arguments()->length()); | 12363 DCHECK_EQ(1, call->arguments()->length()); |
12362 CHECK_ALIVE(VisitExpressions(call->arguments())); | 12364 CHECK_ALIVE(VisitExpressions(call->arguments())); |
12363 HValue* regexp = Pop(); | 12365 HValue* regexp = Pop(); |
12364 HInstruction* result = | 12366 HInstruction* result = |
12365 New<HLoadNamedField>(regexp, nullptr, HObjectAccess::ForJSRegExpFlags()); | 12367 New<HLoadNamedField>(regexp, nullptr, HObjectAccess::ForJSRegExpFlags()); |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13283 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13285 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13284 } | 13286 } |
13285 | 13287 |
13286 #ifdef DEBUG | 13288 #ifdef DEBUG |
13287 graph_->Verify(false); // No full verify. | 13289 graph_->Verify(false); // No full verify. |
13288 #endif | 13290 #endif |
13289 } | 13291 } |
13290 | 13292 |
13291 } // namespace internal | 13293 } // namespace internal |
13292 } // namespace v8 | 13294 } // namespace v8 |
OLD | NEW |