Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: src/runtime/runtime-test.cc

Issue 2701413002: Revert of [wasm] Embedder can control what buffers wasm compilation works on. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/compiler-dispatcher/optimizing-compile-dispatcher.h" 10 #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h"
11 #include "src/compiler.h" 11 #include "src/compiler.h"
12 #include "src/deoptimizer.h" 12 #include "src/deoptimizer.h"
13 #include "src/frames-inl.h" 13 #include "src/frames-inl.h"
14 #include "src/full-codegen/full-codegen.h" 14 #include "src/full-codegen/full-codegen.h"
15 #include "src/isolate-inl.h" 15 #include "src/isolate-inl.h"
16 #include "src/runtime-profiler.h" 16 #include "src/runtime-profiler.h"
17 #include "src/snapshot/code-serializer.h" 17 #include "src/snapshot/code-serializer.h"
18 #include "src/snapshot/natives.h" 18 #include "src/snapshot/natives.h"
19 #include "src/wasm/wasm-module.h" 19 #include "src/wasm/wasm-module.h"
20 #include "src/wasm/wasm-objects.h" 20 #include "src/wasm/wasm-objects.h"
21 21
22 namespace {
23 struct WasmCompileControls {
24 uint32_t MaxWasmBufferSize = std::numeric_limits<uint32_t>::max();
25 bool AllowAnySizeForAsync = true;
26 } g_WasmCompileControls;
27
28 bool IsWasmCompileAllowed(v8::Local<v8::Value> value, bool is_async) {
29 return (is_async && g_WasmCompileControls.AllowAnySizeForAsync) ||
30 (v8::Local<v8::ArrayBuffer>::Cast(value)->ByteLength() <=
31 g_WasmCompileControls.MaxWasmBufferSize);
32 }
33
34 // Use the compile controls for instantiation, too
35 bool IsWasmInstantiateAllowed(v8::Local<v8::WasmCompiledModule> module,
36 v8::Local<v8::Value> ffi, bool is_async) {
37 return (is_async && g_WasmCompileControls.AllowAnySizeForAsync) ||
38 (static_cast<uint32_t>(module->GetWasmWireBytes()->Length()) <=
39 g_WasmCompileControls.MaxWasmBufferSize);
40 }
41 } // namespace
42
43 namespace v8 { 22 namespace v8 {
44 namespace internal { 23 namespace internal {
45 24
46 RUNTIME_FUNCTION(Runtime_ConstructDouble) { 25 RUNTIME_FUNCTION(Runtime_ConstructDouble) {
47 HandleScope scope(isolate); 26 HandleScope scope(isolate);
48 DCHECK_EQ(2, args.length()); 27 DCHECK_EQ(2, args.length());
49 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); 28 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]);
50 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); 29 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]);
51 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; 30 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo;
52 return *isolate->factory()->NewNumber(uint64_to_double(result)); 31 return *isolate->factory()->NewNumber(uint64_to_double(result));
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 Code* target = Code::GetCodeFromTargetAddress(target_address); 422 Code* target = Code::GetCodeFromTargetAddress(target_address);
444 if (target->kind() == target_kind) { 423 if (target->kind() == target_kind) {
445 ++count; 424 ++count;
446 imported_fct = handle(target); 425 imported_fct = handle(target);
447 } 426 }
448 } 427 }
449 CHECK_LE(count, 1); 428 CHECK_LE(count, 1);
450 return isolate->heap()->ToBoolean(count == 1); 429 return isolate->heap()->ToBoolean(count == 1);
451 } 430 }
452 431
453 RUNTIME_FUNCTION(Runtime_SetWasmCompileControls) {
454 HandleScope scope(isolate);
455 CHECK(args.length() == 2);
456 CONVERT_ARG_HANDLE_CHECKED(Smi, block_size, 0);
457 CONVERT_BOOLEAN_ARG_CHECKED(allow_async, 1);
458 g_WasmCompileControls.AllowAnySizeForAsync = allow_async;
459 g_WasmCompileControls.MaxWasmBufferSize =
460 static_cast<uint32_t>(block_size->value());
461 isolate->set_allow_wasm_compile_callback(IsWasmCompileAllowed);
462 return isolate->heap()->undefined_value();
463 }
464
465 RUNTIME_FUNCTION(Runtime_SetWasmInstantiateControls) {
466 HandleScope scope(isolate);
467 CHECK(args.length() == 0);
468 isolate->set_allow_wasm_instantiate_callback(IsWasmInstantiateAllowed);
469 return isolate->heap()->undefined_value();
470 }
471
472 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { 432 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) {
473 HandleScope scope(isolate); 433 HandleScope scope(isolate);
474 DCHECK_EQ(0, args.length()); 434 DCHECK_EQ(0, args.length());
475 isolate->heap()->NotifyContextDisposed(true); 435 isolate->heap()->NotifyContextDisposed(true);
476 return isolate->heap()->undefined_value(); 436 return isolate->heap()->undefined_value();
477 } 437 }
478 438
479 439
480 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { 440 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) {
481 SealHandleScope shs(isolate); 441 SealHandleScope shs(isolate);
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 CHECK(HeapObject::cast(*object)->map()->IsMap()); 856 CHECK(HeapObject::cast(*object)->map()->IsMap());
897 } else { 857 } else {
898 CHECK(object->IsSmi()); 858 CHECK(object->IsSmi());
899 } 859 }
900 #endif 860 #endif
901 return isolate->heap()->ToBoolean(true); 861 return isolate->heap()->ToBoolean(true);
902 } 862 }
903 863
904 } // namespace internal 864 } // namespace internal
905 } // namespace v8 865 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698