OLD | NEW |
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 "src/wasm/wasm-objects.h" | 5 #include "src/wasm/wasm-objects.h" |
6 #include "src/utils.h" | 6 #include "src/utils.h" |
7 | 7 |
8 #include "src/assembler-inl.h" | 8 #include "src/assembler-inl.h" |
9 #include "src/base/iterator.h" | 9 #include "src/base/iterator.h" |
10 #include "src/compiler/wasm-compiler.h" | 10 #include "src/compiler/wasm-compiler.h" |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 uint32_t old_size = 0; | 469 uint32_t old_size = 0; |
470 Address old_mem_start = nullptr; | 470 Address old_mem_start = nullptr; |
471 if (memory_object->has_buffer()) { | 471 if (memory_object->has_buffer()) { |
472 old_buffer = handle(memory_object->buffer()); | 472 old_buffer = handle(memory_object->buffer()); |
473 old_size = old_buffer->byte_length()->Number(); | 473 old_size = old_buffer->byte_length()->Number(); |
474 old_mem_start = static_cast<Address>(old_buffer->backing_store()); | 474 old_mem_start = static_cast<Address>(old_buffer->backing_store()); |
475 } | 475 } |
476 Handle<JSArrayBuffer> new_buffer; | 476 Handle<JSArrayBuffer> new_buffer; |
477 // Return current size if grow by 0. | 477 // Return current size if grow by 0. |
478 if (pages == 0) { | 478 if (pages == 0) { |
479 // Even for pages == 0, we need to attach a new JSArrayBuffer and neuter the | 479 // Even for pages == 0, we need to attach a new JSArrayBuffer with the same |
480 // old one to be spec compliant. | 480 // backing store and neuter the old one to be spec compliant. |
481 if (!old_buffer.is_null() && old_buffer->backing_store() != nullptr) { | 481 if (!old_buffer.is_null() && old_size != 0) { |
482 new_buffer = SetupArrayBuffer(isolate, old_buffer->backing_store(), | 482 new_buffer = SetupArrayBuffer(isolate, old_buffer->backing_store(), |
483 old_size, old_buffer->is_external(), | 483 old_size, old_buffer->is_external(), |
484 old_buffer->has_guard_region()); | 484 old_buffer->has_guard_region()); |
485 memory_object->set_buffer(*new_buffer); | 485 memory_object->set_buffer(*new_buffer); |
486 old_buffer->set_is_neuterable(true); | |
487 if (!old_buffer->has_guard_region()) { | |
488 old_buffer->set_is_external(true); | |
489 isolate->heap()->UnregisterArrayBuffer(*old_buffer); | |
490 } | |
491 // Neuter but don't free the memory because it is now being used by | |
492 // new_buffer. | |
493 old_buffer->Neuter(); | |
494 } | 486 } |
495 DCHECK_EQ(0, old_size % WasmModule::kPageSize); | 487 DCHECK_EQ(0, old_size % WasmModule::kPageSize); |
496 return old_size / WasmModule::kPageSize; | 488 return old_size / WasmModule::kPageSize; |
497 } | 489 } |
498 if (!memory_object->has_instances_link()) { | 490 if (!memory_object->has_instances_link()) { |
499 // Memory object does not have an instance associated with it, just grow | 491 // Memory object does not have an instance associated with it, just grow |
500 uint32_t max_pages; | 492 uint32_t max_pages; |
501 if (memory_object->has_maximum_pages()) { | 493 if (memory_object->has_maximum_pages()) { |
502 max_pages = static_cast<uint32_t>(memory_object->maximum_pages()); | 494 max_pages = static_cast<uint32_t>(memory_object->maximum_pages()); |
503 if (FLAG_wasm_max_mem_pages < max_pages) return -1; | 495 if (FLAG_wasm_max_mem_pages < max_pages) return -1; |
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 if (!array->get(kWrapperInstanceObject)->IsWeakCell()) return false; | 1577 if (!array->get(kWrapperInstanceObject)->IsWeakCell()) return false; |
1586 Isolate* isolate = array->GetIsolate(); | 1578 Isolate* isolate = array->GetIsolate(); |
1587 if (!array->get(kNextInstanceWrapper)->IsUndefined(isolate) && | 1579 if (!array->get(kNextInstanceWrapper)->IsUndefined(isolate) && |
1588 !array->get(kNextInstanceWrapper)->IsFixedArray()) | 1580 !array->get(kNextInstanceWrapper)->IsFixedArray()) |
1589 return false; | 1581 return false; |
1590 if (!array->get(kPreviousInstanceWrapper)->IsUndefined(isolate) && | 1582 if (!array->get(kPreviousInstanceWrapper)->IsUndefined(isolate) && |
1591 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) | 1583 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) |
1592 return false; | 1584 return false; |
1593 return true; | 1585 return true; |
1594 } | 1586 } |
OLD | NEW |