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

Unified Diff: src/layout-descriptor.cc

Issue 1084793004: LayoutDescriptor should inherit from JSTypedArray (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/layout-descriptor.h ('k') | src/layout-descriptor-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/layout-descriptor.cc
diff --git a/src/layout-descriptor.cc b/src/layout-descriptor.cc
index 66a1f0fb07950404a4d36c9bca9b5c4a6be15014..312429f0c6d40a63811f9fafdfd045e2e1aaaba6 100644
--- a/src/layout-descriptor.cc
+++ b/src/layout-descriptor.cc
@@ -106,8 +106,12 @@ Handle<LayoutDescriptor> LayoutDescriptor::EnsureCapacity(
DCHECK(new_layout_descriptor->IsSlowLayout());
if (layout_descriptor->IsSlowLayout()) {
- memcpy(new_layout_descriptor->DataPtr(), layout_descriptor->DataPtr(),
- layout_descriptor->DataSize());
+ DisallowHeapAllocation no_gc;
+ Handle<FixedTypedArrayBase> elements(
+ FixedTypedArrayBase::cast(layout_descriptor->elements()));
+ Handle<FixedTypedArrayBase> new_elements(
+ FixedTypedArrayBase::cast(new_layout_descriptor->elements()));
+ memcpy(new_elements->DataPtr(), elements->DataPtr(), elements->DataSize());
return new_layout_descriptor;
} else {
// Fast layout.
@@ -150,7 +154,7 @@ bool LayoutDescriptor::IsTagged(int field_index, int max_sequence_length,
// This is a contiguous sequence till the end of current word, proceed
// counting in the subsequent words.
if (IsSlowLayout()) {
- int len = length();
+ int len = Smi::cast(length())->value();
++layout_word_index;
for (; layout_word_index < len; layout_word_index++) {
value = get_scalar(layout_word_index);
@@ -241,13 +245,20 @@ LayoutDescriptor* LayoutDescriptor::Trim(Heap* heap, Map* map,
// Trim, clean and reinitialize this slow-mode layout descriptor.
int array_length = GetSlowModeBackingStoreLength(layout_descriptor_length);
- int current_length = length();
+ int current_length = Smi::cast(length())->value();
if (current_length != array_length) {
DCHECK_LT(array_length, current_length);
int delta = current_length - array_length;
- heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(this, delta);
+ heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(elements(), delta);
+ set_byte_length(Smi::FromInt(array_length * 4));
+ set_length(Smi::FromInt(array_length));
+ }
+ {
+ DisallowHeapAllocation no_gc;
+ Handle<FixedTypedArrayBase> fixed_array(
+ FixedTypedArrayBase::cast(elements()));
+ memset(fixed_array->DataPtr(), 0, fixed_array->DataSize());
}
- memset(DataPtr(), 0, DataSize());
LayoutDescriptor* layout_descriptor =
Initialize(this, map, descriptors, num_descriptors);
DCHECK_EQ(this, layout_descriptor);
« no previous file with comments | « src/layout-descriptor.h ('k') | src/layout-descriptor-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698