| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/builtins/builtins.h" | 5 #include "src/builtins/builtins.h" |
| 6 #include "src/builtins/builtins-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
| 7 | 7 |
| 8 #include "src/string-builder.h" | 8 #include "src/string-builder.h" |
| 9 #include "src/wasm/wasm-module.h" | 9 #include "src/wasm/wasm-module.h" |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 const bool is_wasm_object = | 51 const bool is_wasm_object = |
| 52 receiver->IsJSObject() && wasm::IsWasmObject(JSObject::cast(*receiver)); | 52 receiver->IsJSObject() && wasm::IsWasmObject(JSObject::cast(*receiver)); |
| 53 if (!fun->IsJSFunction() && !is_wasm_object) { | 53 if (!fun->IsJSFunction() && !is_wasm_object) { |
| 54 THROW_NEW_ERROR_RETURN_FAILURE( | 54 THROW_NEW_ERROR_RETURN_FAILURE( |
| 55 isolate, NewTypeError(MessageTemplate::kCallSiteExpectsFunction, | 55 isolate, NewTypeError(MessageTemplate::kCallSiteExpectsFunction, |
| 56 Object::TypeOf(isolate, receiver), | 56 Object::TypeOf(isolate, receiver), |
| 57 Object::TypeOf(isolate, fun))); | 57 Object::TypeOf(isolate, fun))); |
| 58 } | 58 } |
| 59 | 59 |
| 60 if (is_wasm_object) { | 60 if (is_wasm_object) { |
| 61 DCHECK(!fun->IsJSFunction()); | 61 DCHECK(fun->IsSmi()); |
| 62 DCHECK(wasm::GetNumberOfFunctions(JSObject::cast(*receiver)) > |
| 63 Smi::cast(*fun)->value()); |
| 64 |
| 62 SET_CALLSITE_PROPERTY(obj, call_site_wasm_obj_symbol, receiver); | 65 SET_CALLSITE_PROPERTY(obj, call_site_wasm_obj_symbol, receiver); |
| 63 | |
| 64 Handle<Object> fun_index; | |
| 65 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, fun_index, | |
| 66 Object::ToUint32(isolate, fun)); | |
| 67 SET_CALLSITE_PROPERTY(obj, call_site_wasm_func_index_symbol, fun); | 66 SET_CALLSITE_PROPERTY(obj, call_site_wasm_func_index_symbol, fun); |
| 68 } else { | 67 } else { |
| 69 DCHECK(fun->IsJSFunction()); | 68 DCHECK(fun->IsJSFunction()); |
| 70 SET_CALLSITE_PROPERTY(obj, call_site_receiver_symbol, receiver); | 69 SET_CALLSITE_PROPERTY(obj, call_site_receiver_symbol, receiver); |
| 71 SET_CALLSITE_PROPERTY(obj, call_site_function_symbol, fun); | 70 SET_CALLSITE_PROPERTY(obj, call_site_function_symbol, fun); |
| 72 } | 71 } |
| 73 | 72 |
| 74 Handle<Object> pos_int32; | 73 DCHECK(pos->IsSmi()); |
| 75 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, pos_int32, | 74 SET_CALLSITE_PROPERTY(obj, call_site_position_symbol, pos); |
| 76 Object::ToInt32(isolate, pos)); | |
| 77 SET_CALLSITE_PROPERTY(obj, call_site_position_symbol, pos_int32); | |
| 78 SET_CALLSITE_PROPERTY( | 75 SET_CALLSITE_PROPERTY( |
| 79 obj, call_site_strict_symbol, | 76 obj, call_site_strict_symbol, |
| 80 isolate->factory()->ToBoolean(strict_mode->BooleanValue())); | 77 isolate->factory()->ToBoolean(strict_mode->BooleanValue())); |
| 81 | 78 |
| 82 return *obj; | 79 return *obj; |
| 83 } | 80 } |
| 84 | 81 |
| 85 #undef SET_CALLSITE_PROPERTY | 82 #undef SET_CALLSITE_PROPERTY |
| 86 | 83 |
| 87 namespace { | 84 namespace { |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 isolate, AppendFileLocation(isolate, recv, &call_site, &builder)); | 602 isolate, AppendFileLocation(isolate, recv, &call_site, &builder)); |
| 606 builder.AppendCString(")"); | 603 builder.AppendCString(")"); |
| 607 | 604 |
| 608 RETURN_RESULT_OR_FAILURE(isolate, builder.Finish()); | 605 RETURN_RESULT_OR_FAILURE(isolate, builder.Finish()); |
| 609 } | 606 } |
| 610 | 607 |
| 611 #undef CHECK_CALLSITE | 608 #undef CHECK_CALLSITE |
| 612 | 609 |
| 613 } // namespace internal | 610 } // namespace internal |
| 614 } // namespace v8 | 611 } // namespace v8 |
| OLD | NEW |