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 <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
10 #include "src/ast/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
(...skipping 9223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9234 int argc, BailoutId ast_id, ApiCallType call_type, | 9234 int argc, BailoutId ast_id, ApiCallType call_type, |
9235 TailCallMode syntactic_tail_call_mode) { | 9235 TailCallMode syntactic_tail_call_mode) { |
9236 if (function->IsJSFunction() && | 9236 if (function->IsJSFunction() && |
9237 Handle<JSFunction>::cast(function)->context()->native_context() != | 9237 Handle<JSFunction>::cast(function)->context()->native_context() != |
9238 top_info()->closure()->context()->native_context()) { | 9238 top_info()->closure()->context()->native_context()) { |
9239 return false; | 9239 return false; |
9240 } | 9240 } |
9241 if (syntactic_tail_call_mode == TailCallMode::kAllow) { | 9241 if (syntactic_tail_call_mode == TailCallMode::kAllow) { |
9242 return false; | 9242 return false; |
9243 } | 9243 } |
| 9244 if (argc > CallApiCallbackStub::kArgMax) { |
| 9245 return false; |
| 9246 } |
| 9247 |
9244 CallOptimization optimization(function); | 9248 CallOptimization optimization(function); |
9245 if (!optimization.is_simple_api_call()) return false; | 9249 if (!optimization.is_simple_api_call()) return false; |
9246 Handle<Map> holder_map; | 9250 Handle<Map> holder_map; |
9247 for (int i = 0; i < receiver_maps->length(); ++i) { | 9251 for (int i = 0; i < receiver_maps->length(); ++i) { |
9248 auto map = receiver_maps->at(i); | 9252 auto map = receiver_maps->at(i); |
9249 // Don't inline calls to receivers requiring accesschecks. | 9253 // Don't inline calls to receivers requiring accesschecks. |
9250 if (map->is_access_check_needed()) return false; | 9254 if (map->is_access_check_needed()) return false; |
9251 } | 9255 } |
9252 if (call_type == kCallApiFunction) { | 9256 if (call_type == kCallApiFunction) { |
9253 // Cannot embed a direct reference to the global proxy map | 9257 // Cannot embed a direct reference to the global proxy map |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9329 ApiFunction fun(v8::ToCData<Address>(api_call_info->callback())); | 9333 ApiFunction fun(v8::ToCData<Address>(api_call_info->callback())); |
9330 ExternalReference ref = ExternalReference(&fun, | 9334 ExternalReference ref = ExternalReference(&fun, |
9331 ExternalReference::DIRECT_API_CALL, | 9335 ExternalReference::DIRECT_API_CALL, |
9332 isolate()); | 9336 isolate()); |
9333 HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); | 9337 HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); |
9334 | 9338 |
9335 HValue* op_vals[] = {context(), Add<HConstant>(function), call_data, holder, | 9339 HValue* op_vals[] = {context(), Add<HConstant>(function), call_data, holder, |
9336 api_function_address, nullptr}; | 9340 api_function_address, nullptr}; |
9337 | 9341 |
9338 HInstruction* call = nullptr; | 9342 HInstruction* call = nullptr; |
| 9343 CHECK(argc <= CallApiCallbackStub::kArgMax); |
9339 if (!is_function) { | 9344 if (!is_function) { |
9340 CallApiAccessorStub stub(isolate(), is_store, call_data_undefined, | 9345 CallApiCallbackStub stub(isolate(), is_store, call_data_undefined, |
9341 !optimization.is_constant_call()); | 9346 !optimization.is_constant_call()); |
9342 Handle<Code> code = stub.GetCode(); | 9347 Handle<Code> code = stub.GetCode(); |
9343 HConstant* code_value = Add<HConstant>(code); | 9348 HConstant* code_value = Add<HConstant>(code); |
9344 ApiAccessorDescriptor descriptor(isolate()); | |
9345 call = New<HCallWithDescriptor>( | 9349 call = New<HCallWithDescriptor>( |
9346 code_value, argc + 1, descriptor, | 9350 code_value, argc + 1, stub.GetCallInterfaceDescriptor(), |
9347 Vector<HValue*>(op_vals, arraysize(op_vals) - 1)); | 9351 Vector<HValue*>(op_vals, arraysize(op_vals) - 1)); |
9348 } else if (argc <= CallApiFunctionWithFixedArgsStub::kMaxFixedArgs) { | 9352 } else { |
9349 CallApiFunctionWithFixedArgsStub stub(isolate(), argc, call_data_undefined); | 9353 CallApiCallbackStub stub(isolate(), argc, call_data_undefined); |
9350 Handle<Code> code = stub.GetCode(); | 9354 Handle<Code> code = stub.GetCode(); |
9351 HConstant* code_value = Add<HConstant>(code); | 9355 HConstant* code_value = Add<HConstant>(code); |
9352 ApiFunctionWithFixedArgsDescriptor descriptor(isolate()); | |
9353 call = New<HCallWithDescriptor>( | 9356 call = New<HCallWithDescriptor>( |
9354 code_value, argc + 1, descriptor, | 9357 code_value, argc + 1, stub.GetCallInterfaceDescriptor(), |
9355 Vector<HValue*>(op_vals, arraysize(op_vals) - 1)); | 9358 Vector<HValue*>(op_vals, arraysize(op_vals) - 1)); |
9356 Drop(1); // Drop function. | 9359 Drop(1); // Drop function. |
9357 } else { | |
9358 op_vals[arraysize(op_vals) - 1] = Add<HConstant>(argc); | |
9359 CallApiFunctionStub stub(isolate(), call_data_undefined); | |
9360 Handle<Code> code = stub.GetCode(); | |
9361 HConstant* code_value = Add<HConstant>(code); | |
9362 ApiFunctionDescriptor descriptor(isolate()); | |
9363 call = | |
9364 New<HCallWithDescriptor>(code_value, argc + 1, descriptor, | |
9365 Vector<HValue*>(op_vals, arraysize(op_vals))); | |
9366 Drop(1); // Drop function. | |
9367 } | 9360 } |
9368 | 9361 |
9369 ast_context()->ReturnInstruction(call, ast_id); | 9362 ast_context()->ReturnInstruction(call, ast_id); |
9370 return true; | 9363 return true; |
9371 } | 9364 } |
9372 | 9365 |
9373 | 9366 |
9374 void HOptimizedGraphBuilder::HandleIndirectCall(Call* expr, HValue* function, | 9367 void HOptimizedGraphBuilder::HandleIndirectCall(Call* expr, HValue* function, |
9375 int arguments_count) { | 9368 int arguments_count) { |
9376 Handle<JSFunction> known_function; | 9369 Handle<JSFunction> known_function; |
(...skipping 4140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13517 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13510 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13518 } | 13511 } |
13519 | 13512 |
13520 #ifdef DEBUG | 13513 #ifdef DEBUG |
13521 graph_->Verify(false); // No full verify. | 13514 graph_->Verify(false); // No full verify. |
13522 #endif | 13515 #endif |
13523 } | 13516 } |
13524 | 13517 |
13525 } // namespace internal | 13518 } // namespace internal |
13526 } // namespace v8 | 13519 } // namespace v8 |
OLD | NEW |