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

Side by Side Diff: src/objects.cc

Issue 1305383003: Move runtime helper for JSArrayBuffer onto objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-runtime-helpers-2
Patch Set: Self-nit. Created 5 years, 3 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.h ('k') | src/runtime/runtime.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 15574 matching lines...) Expand 10 before | Expand all | Expand 10 after
15585 15585
15586 void JSArrayBuffer::Neuter() { 15586 void JSArrayBuffer::Neuter() {
15587 CHECK(is_neuterable()); 15587 CHECK(is_neuterable());
15588 CHECK(is_external()); 15588 CHECK(is_external());
15589 set_backing_store(NULL); 15589 set_backing_store(NULL);
15590 set_byte_length(Smi::FromInt(0)); 15590 set_byte_length(Smi::FromInt(0));
15591 set_was_neutered(true); 15591 set_was_neutered(true);
15592 } 15592 }
15593 15593
15594 15594
15595 void JSArrayBuffer::Setup(Handle<JSArrayBuffer> array_buffer, Isolate* isolate,
15596 bool is_external, void* data, size_t allocated_length,
15597 SharedFlag shared) {
15598 DCHECK(array_buffer->GetInternalFieldCount() ==
15599 v8::ArrayBuffer::kInternalFieldCount);
15600 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) {
15601 array_buffer->SetInternalField(i, Smi::FromInt(0));
15602 }
15603 array_buffer->set_backing_store(data);
15604 array_buffer->set_bit_field(0);
15605 array_buffer->set_is_external(is_external);
15606 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared);
15607 array_buffer->set_is_shared(shared == SharedFlag::kShared);
15608
15609 if (data && !is_external) {
15610 isolate->heap()->RegisterNewArrayBuffer(
15611 isolate->heap()->InNewSpace(*array_buffer), data, allocated_length);
15612 }
15613
15614 Handle<Object> byte_length =
15615 isolate->factory()->NewNumberFromSize(allocated_length);
15616 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber());
15617 array_buffer->set_byte_length(*byte_length);
15618 }
15619
15620
15621 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer,
15622 Isolate* isolate,
15623 size_t allocated_length,
15624 bool initialize, SharedFlag shared) {
15625 void* data;
15626 CHECK(isolate->array_buffer_allocator() != NULL);
15627 // Prevent creating array buffers when serializing.
15628 DCHECK(!isolate->serializer_enabled());
15629 if (allocated_length != 0) {
15630 if (initialize) {
15631 data = isolate->array_buffer_allocator()->Allocate(allocated_length);
15632 } else {
15633 data = isolate->array_buffer_allocator()->AllocateUninitialized(
15634 allocated_length);
15635 }
15636 if (data == NULL) return false;
15637 } else {
15638 data = NULL;
15639 }
15640
15641 JSArrayBuffer::Setup(array_buffer, isolate, false, data, allocated_length,
15642 shared);
15643 return true;
15644 }
15645
15646
15595 Handle<JSArrayBuffer> JSTypedArray::MaterializeArrayBuffer( 15647 Handle<JSArrayBuffer> JSTypedArray::MaterializeArrayBuffer(
15596 Handle<JSTypedArray> typed_array) { 15648 Handle<JSTypedArray> typed_array) {
15597 15649
15598 Handle<Map> map(typed_array->map()); 15650 Handle<Map> map(typed_array->map());
15599 Isolate* isolate = typed_array->GetIsolate(); 15651 Isolate* isolate = typed_array->GetIsolate();
15600 15652
15601 DCHECK(IsFixedTypedArrayElementsKind(map->elements_kind())); 15653 DCHECK(IsFixedTypedArrayElementsKind(map->elements_kind()));
15602 15654
15603 Handle<FixedTypedArrayBase> fixed_typed_array( 15655 Handle<FixedTypedArrayBase> fixed_typed_array(
15604 FixedTypedArrayBase::cast(typed_array->elements())); 15656 FixedTypedArrayBase::cast(typed_array->elements()));
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
15771 if (cell->value() != *new_value) { 15823 if (cell->value() != *new_value) {
15772 cell->set_value(*new_value); 15824 cell->set_value(*new_value);
15773 Isolate* isolate = cell->GetIsolate(); 15825 Isolate* isolate = cell->GetIsolate();
15774 cell->dependent_code()->DeoptimizeDependentCodeGroup( 15826 cell->dependent_code()->DeoptimizeDependentCodeGroup(
15775 isolate, DependentCode::kPropertyCellChangedGroup); 15827 isolate, DependentCode::kPropertyCellChangedGroup);
15776 } 15828 }
15777 } 15829 }
15778 15830
15779 } // namespace internal 15831 } // namespace internal
15780 } // namespace v8 15832 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698