| 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 9170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9181 bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<Object> function, | 9181 bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<Object> function, |
| 9182 HValue* receiver, | 9182 HValue* receiver, |
| 9183 SmallMapList* receiver_maps, | 9183 SmallMapList* receiver_maps, |
| 9184 int argc, BailoutId ast_id, | 9184 int argc, BailoutId ast_id, |
| 9185 ApiCallType call_type) { | 9185 ApiCallType call_type) { |
| 9186 if (function->IsJSFunction() && | 9186 if (function->IsJSFunction() && |
| 9187 Handle<JSFunction>::cast(function)->context()->native_context() != | 9187 Handle<JSFunction>::cast(function)->context()->native_context() != |
| 9188 top_info()->closure()->context()->native_context()) { | 9188 top_info()->closure()->context()->native_context()) { |
| 9189 return false; | 9189 return false; |
| 9190 } | 9190 } |
| 9191 if (argc >= CallApiCallbackStub::kArgMax) { |
| 9192 return false; |
| 9193 } |
| 9194 |
| 9191 CallOptimization optimization(function); | 9195 CallOptimization optimization(function); |
| 9192 if (!optimization.is_simple_api_call()) return false; | 9196 if (!optimization.is_simple_api_call()) return false; |
| 9193 Handle<Map> holder_map; | 9197 Handle<Map> holder_map; |
| 9194 for (int i = 0; i < receiver_maps->length(); ++i) { | 9198 for (int i = 0; i < receiver_maps->length(); ++i) { |
| 9195 auto map = receiver_maps->at(i); | 9199 auto map = receiver_maps->at(i); |
| 9196 // Don't inline calls to receivers requiring accesschecks. | 9200 // Don't inline calls to receivers requiring accesschecks. |
| 9197 if (map->is_access_check_needed()) return false; | 9201 if (map->is_access_check_needed()) return false; |
| 9198 } | 9202 } |
| 9199 if (call_type == kCallApiFunction) { | 9203 if (call_type == kCallApiFunction) { |
| 9200 // Cannot embed a direct reference to the global proxy map | 9204 // Cannot embed a direct reference to the global proxy map |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9276 ApiFunction fun(v8::ToCData<Address>(api_call_info->callback())); | 9280 ApiFunction fun(v8::ToCData<Address>(api_call_info->callback())); |
| 9277 ExternalReference ref = ExternalReference(&fun, | 9281 ExternalReference ref = ExternalReference(&fun, |
| 9278 ExternalReference::DIRECT_API_CALL, | 9282 ExternalReference::DIRECT_API_CALL, |
| 9279 isolate()); | 9283 isolate()); |
| 9280 HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); | 9284 HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); |
| 9281 | 9285 |
| 9282 HValue* op_vals[] = {context(), Add<HConstant>(function), call_data, holder, | 9286 HValue* op_vals[] = {context(), Add<HConstant>(function), call_data, holder, |
| 9283 api_function_address, nullptr}; | 9287 api_function_address, nullptr}; |
| 9284 | 9288 |
| 9285 HInstruction* call = nullptr; | 9289 HInstruction* call = nullptr; |
| 9290 CHECK(argc <= CallApiCallbackStub::kArgMax); |
| 9286 if (!is_function) { | 9291 if (!is_function) { |
| 9287 CallApiAccessorStub stub(isolate(), is_store, call_data_undefined, | 9292 CallApiCallbackStub stub(isolate(), is_store, call_data_undefined, |
| 9288 !optimization.is_constant_call()); | 9293 !optimization.is_constant_call()); |
| 9289 Handle<Code> code = stub.GetCode(); | 9294 Handle<Code> code = stub.GetCode(); |
| 9290 HConstant* code_value = Add<HConstant>(code); | 9295 HConstant* code_value = Add<HConstant>(code); |
| 9291 ApiAccessorDescriptor descriptor(isolate()); | |
| 9292 call = New<HCallWithDescriptor>( | 9296 call = New<HCallWithDescriptor>( |
| 9293 code_value, argc + 1, descriptor, | 9297 code_value, argc + 1, stub.GetCallInterfaceDescriptor(), |
| 9294 Vector<HValue*>(op_vals, arraysize(op_vals) - 1)); | 9298 Vector<HValue*>(op_vals, arraysize(op_vals) - 1)); |
| 9295 } else if (argc <= CallApiFunctionWithFixedArgsStub::kMaxFixedArgs) { | 9299 } else { |
| 9296 CallApiFunctionWithFixedArgsStub stub(isolate(), argc, call_data_undefined); | 9300 CallApiCallbackStub stub(isolate(), argc, call_data_undefined); |
| 9297 Handle<Code> code = stub.GetCode(); | 9301 Handle<Code> code = stub.GetCode(); |
| 9298 HConstant* code_value = Add<HConstant>(code); | 9302 HConstant* code_value = Add<HConstant>(code); |
| 9299 ApiFunctionWithFixedArgsDescriptor descriptor(isolate()); | |
| 9300 call = New<HCallWithDescriptor>( | 9303 call = New<HCallWithDescriptor>( |
| 9301 code_value, argc + 1, descriptor, | 9304 code_value, argc + 1, stub.GetCallInterfaceDescriptor(), |
| 9302 Vector<HValue*>(op_vals, arraysize(op_vals) - 1)); | 9305 Vector<HValue*>(op_vals, arraysize(op_vals) - 1)); |
| 9303 Drop(1); // Drop function. | 9306 Drop(1); // Drop function. |
| 9304 } else { | |
| 9305 op_vals[arraysize(op_vals) - 1] = Add<HConstant>(argc); | |
| 9306 CallApiFunctionStub stub(isolate(), call_data_undefined); | |
| 9307 Handle<Code> code = stub.GetCode(); | |
| 9308 HConstant* code_value = Add<HConstant>(code); | |
| 9309 ApiFunctionDescriptor descriptor(isolate()); | |
| 9310 call = | |
| 9311 New<HCallWithDescriptor>(code_value, argc + 1, descriptor, | |
| 9312 Vector<HValue*>(op_vals, arraysize(op_vals))); | |
| 9313 Drop(1); // Drop function. | |
| 9314 } | 9307 } |
| 9315 | 9308 |
| 9316 ast_context()->ReturnInstruction(call, ast_id); | 9309 ast_context()->ReturnInstruction(call, ast_id); |
| 9317 return true; | 9310 return true; |
| 9318 } | 9311 } |
| 9319 | 9312 |
| 9320 | 9313 |
| 9321 void HOptimizedGraphBuilder::HandleIndirectCall(Call* expr, HValue* function, | 9314 void HOptimizedGraphBuilder::HandleIndirectCall(Call* expr, HValue* function, |
| 9322 int arguments_count) { | 9315 int arguments_count) { |
| 9323 Handle<JSFunction> known_function; | 9316 Handle<JSFunction> known_function; |
| (...skipping 4129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13453 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13446 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13454 } | 13447 } |
| 13455 | 13448 |
| 13456 #ifdef DEBUG | 13449 #ifdef DEBUG |
| 13457 graph_->Verify(false); // No full verify. | 13450 graph_->Verify(false); // No full verify. |
| 13458 #endif | 13451 #endif |
| 13459 } | 13452 } |
| 13460 | 13453 |
| 13461 } // namespace internal | 13454 } // namespace internal |
| 13462 } // namespace v8 | 13455 } // namespace v8 |
| OLD | NEW |