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

Side by Side Diff: src/wasm/wasm-module.cc

Issue 2388303008: [wasm] Remove dangerous ByteArray::data accessor. (Closed)
Patch Set: Created 4 years, 2 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/objects-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 <memory> 5 #include <memory>
6 6
7 #include "src/base/atomic-utils.h" 7 #include "src/base/atomic-utils.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 9
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 if (target->IsJSFunction()) { 507 if (target->IsJSFunction()) {
508 Handle<JSFunction> func = Handle<JSFunction>::cast(target); 508 Handle<JSFunction> func = Handle<JSFunction>::cast(target);
509 export_wrapper_code = handle(func->code()); 509 export_wrapper_code = handle(func->code());
510 if (export_wrapper_code->kind() == Code::JS_TO_WASM_FUNCTION) { 510 if (export_wrapper_code->kind() == Code::JS_TO_WASM_FUNCTION) {
511 int exported_param_count = 511 int exported_param_count =
512 Smi::cast(func->GetInternalField(kInternalArity))->value(); 512 Smi::cast(func->GetInternalField(kInternalArity))->value();
513 Handle<ByteArray> exportedSig = Handle<ByteArray>( 513 Handle<ByteArray> exportedSig = Handle<ByteArray>(
514 ByteArray::cast(func->GetInternalField(kInternalSignature))); 514 ByteArray::cast(func->GetInternalField(kInternalSignature)));
515 if (exported_param_count == param_count && 515 if (exported_param_count == param_count &&
516 exportedSig->length() == sig_data->length() && 516 exportedSig->length() == sig_data->length() &&
517 memcmp(exportedSig->data(), sig_data->data(), 517 memcmp(exportedSig->GetDataStartAddress(),
518 exportedSig->length()) == 0) { 518 sig_data->GetDataStartAddress(), exportedSig->length()) == 0) {
519 isMatch = true; 519 isMatch = true;
520 } 520 }
521 } 521 }
522 } 522 }
523 if (isMatch) { 523 if (isMatch) {
524 int wasm_count = 0; 524 int wasm_count = 0;
525 int const mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); 525 int const mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
526 for (RelocIterator it(*export_wrapper_code, mask); !it.done(); it.next()) { 526 for (RelocIterator it(*export_wrapper_code, mask); !it.done(); it.next()) {
527 RelocInfo* rinfo = it.rinfo(); 527 RelocInfo* rinfo = it.rinfo();
528 Address target_address = rinfo->target_address(); 528 Address target_address = rinfo->target_address();
529 Code* target = Code::GetCodeFromTargetAddress(target_address); 529 Code* target = Code::GetCodeFromTargetAddress(target_address);
530 if (target->kind() == Code::WASM_FUNCTION) { 530 if (target->kind() == Code::WASM_FUNCTION) {
531 ++wasm_count; 531 ++wasm_count;
532 code = handle(target); 532 code = handle(target);
533 } 533 }
534 } 534 }
535 DCHECK(wasm_count == 1); 535 DCHECK(wasm_count == 1);
536 return code; 536 return code;
537 } else { 537 } else {
538 // Copy the signature to avoid a raw pointer into a heap object when 538 // Copy the signature to avoid a raw pointer into a heap object when
539 // GC can happen. 539 // GC can happen.
540 Zone zone(isolate->allocator()); 540 Zone zone(isolate->allocator());
541 MachineRepresentation* reps = 541 MachineRepresentation* reps =
542 zone.NewArray<MachineRepresentation>(sig_data_size); 542 zone.NewArray<MachineRepresentation>(sig_data_size);
543 memcpy(reps, sig_data->data(), 543 memcpy(reps, sig_data->GetDataStartAddress(),
544 sizeof(MachineRepresentation) * sig_data_size); 544 sizeof(MachineRepresentation) * sig_data_size);
545 FunctionSig sig(ret_count, param_count, reps); 545 FunctionSig sig(ret_count, param_count, reps);
546 546
547 return compiler::CompileWasmToJSWrapper(isolate, target, &sig, index, 547 return compiler::CompileWasmToJSWrapper(isolate, target, &sig, index,
548 module_name, function_name); 548 module_name, function_name);
549 } 549 }
550 } 550 }
551 551
552 void InitializeParallelCompilation( 552 void InitializeParallelCompilation(
553 Isolate* isolate, const std::vector<WasmFunction>& functions, 553 Isolate* isolate, const std::vector<WasmFunction>& functions,
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 WasmCompiledModule* compiled_module = 1913 WasmCompiledModule* compiled_module =
1914 WasmCompiledModule::cast(instance->GetInternalField(kWasmCompiledModule)); 1914 WasmCompiledModule::cast(instance->GetInternalField(kWasmCompiledModule));
1915 CHECK(compiled_module->has_weak_module_object()); 1915 CHECK(compiled_module->has_weak_module_object());
1916 CHECK(compiled_module->ptr_to_weak_module_object()->cleared()); 1916 CHECK(compiled_module->ptr_to_weak_module_object()->cleared());
1917 } 1917 }
1918 1918
1919 } // namespace testing 1919 } // namespace testing
1920 } // namespace wasm 1920 } // namespace wasm
1921 } // namespace internal 1921 } // namespace internal
1922 } // namespace v8 1922 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698