OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 DCHECK(args.length() == 1); | 275 DCHECK(args.length() == 1); |
276 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 276 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
277 function->ClearTypeFeedbackInfo(); | 277 function->ClearTypeFeedbackInfo(); |
278 Code* unoptimized = function->shared()->code(); | 278 Code* unoptimized = function->shared()->code(); |
279 if (unoptimized->kind() == Code::FUNCTION) { | 279 if (unoptimized->kind() == Code::FUNCTION) { |
280 unoptimized->ClearInlineCaches(); | 280 unoptimized->ClearInlineCaches(); |
281 } | 281 } |
282 return isolate->heap()->undefined_value(); | 282 return isolate->heap()->undefined_value(); |
283 } | 283 } |
284 | 284 |
285 RUNTIME_FUNCTION(Runtime_CheckImportExportFunction) { | |
Mircea Trofin
2016/08/03 22:52:16
add a comment saying that this only supports the c
| |
286 HandleScope scope(isolate); | |
287 DCHECK(args.length() == 2); | |
288 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | |
289 // If type is 0, it means that it is supposed to be a direct call to WASM | |
290 // function | |
291 // If type is 1, it means that it is supposed to have wrappers | |
292 CONVERT_ARG_HANDLE_CHECKED(Smi, type, 1); | |
293 Handle<Code> export_code = handle(function->code()); | |
294 DCHECK(export_code->kind() == Code::JS_TO_WASM_FUNCTION); | |
295 int const mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); | |
296 // check the type of the $export_fct | |
297 Handle<Code> export_fct; | |
298 int count = 0; | |
299 for (RelocIterator it(*export_code, mask); !it.done(); it.next()) { | |
300 RelocInfo* rinfo = it.rinfo(); | |
301 Address target_address = rinfo->target_address(); | |
302 Code* target = Code::GetCodeFromTargetAddress(target_address); | |
303 if (target->kind() == Code::WASM_FUNCTION) { | |
304 ++count; | |
305 export_fct = handle(target); | |
306 } | |
307 } | |
308 DCHECK(export_fct->kind() == Code::WASM_FUNCTION && count == 1); | |
309 // check the type of the $increment | |
310 Handle<Code> increment_fct; | |
Mircea Trofin
2016/08/03 22:52:16
The notion of "increment" is probably tied to the
| |
311 count = 0; | |
312 for (RelocIterator it(*export_fct, mask); !it.done(); it.next()) { | |
313 RelocInfo* rinfo = it.rinfo(); | |
314 Address target_address = rinfo->target_address(); | |
315 Code* target = Code::GetCodeFromTargetAddress(target_address); | |
316 if (target->kind() == Code::WASM_FUNCTION) { | |
317 ++count; | |
318 increment_fct = handle(target); | |
319 } | |
320 } | |
321 DCHECK(increment_fct->kind() == Code::WASM_FUNCTION && count == 1); | |
Mircea Trofin
2016/08/03 22:52:16
you probably want to check here that increment_fct
| |
322 // check the type of the imported exported function, it should be also a WASM | |
323 // function in our case | |
324 Handle<Code> imported_fct; | |
325 Code::Kind target_kind; | |
326 count = 0; | |
327 for (RelocIterator it(*increment_fct, mask); !it.done(); it.next()) { | |
328 RelocInfo* rinfo = it.rinfo(); | |
329 Address target_address = rinfo->target_address(); | |
330 Code* target = Code::GetCodeFromTargetAddress(target_address); | |
331 if (type->value() == 0) | |
Mircea Trofin
2016/08/03 22:52:16
you need {}
Mircea Trofin
2016/08/03 22:52:16
move out of the for loop the target_kind assignmen
| |
332 target_kind = Code::WASM_FUNCTION; | |
333 else if (type->value() == 1) | |
334 target_kind = Code::WASM_TO_JS_FUNCTION; | |
Mircea Trofin
2016/08/03 22:52:16
{} also - because the assignment is on the second
| |
335 if (target->kind() == target_kind) { | |
336 ++count; | |
337 imported_fct = handle(target); | |
338 } | |
339 } | |
340 DCHECK(imported_fct->kind() == target_kind && count == 1); | |
341 return isolate->heap()->undefined_value(); | |
342 } | |
285 | 343 |
286 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { | 344 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { |
287 HandleScope scope(isolate); | 345 HandleScope scope(isolate); |
288 DCHECK(args.length() == 0); | 346 DCHECK(args.length() == 0); |
289 isolate->heap()->NotifyContextDisposed(true); | 347 isolate->heap()->NotifyContextDisposed(true); |
290 return isolate->heap()->undefined_value(); | 348 return isolate->heap()->undefined_value(); |
291 } | 349 } |
292 | 350 |
293 | 351 |
294 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { | 352 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
574 | 632 |
575 RUNTIME_FUNCTION(Runtime_SpeciesProtector) { | 633 RUNTIME_FUNCTION(Runtime_SpeciesProtector) { |
576 SealHandleScope shs(isolate); | 634 SealHandleScope shs(isolate); |
577 DCHECK_EQ(0, args.length()); | 635 DCHECK_EQ(0, args.length()); |
578 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact()); | 636 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact()); |
579 } | 637 } |
580 | 638 |
581 | 639 |
582 } // namespace internal | 640 } // namespace internal |
583 } // namespace v8 | 641 } // namespace v8 |
OLD | NEW |