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

Unified Diff: src/factory.cc

Issue 2498413002: Initialize internal fields in Factory::NewJSTypedArray and NewJSDataView. (Closed)
Patch Set: unit tests Created 4 years, 1 month 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 | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 4f42888164de48ec0b5f88a01b886f27ad80065e..6719160dbd1bee8cab1ffbc2a5a492a0f25e037c 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -2001,6 +2001,12 @@ void SetupArrayBufferView(i::Isolate* isolate,
DCHECK(byte_offset + byte_length <=
static_cast<size_t>(buffer->byte_length()->Number()));
+ DCHECK_EQ(obj->GetInternalFieldCount(),
+ v8::ArrayBufferView::kInternalFieldCount);
+ for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
+ obj->SetInternalField(i, Smi::kZero);
+ }
+
obj->set_buffer(*buffer);
i::Handle<i::Object> byte_offset_object =
@@ -2070,6 +2076,11 @@ Handle<JSTypedArray> Factory::NewJSTypedArray(ElementsKind elements_kind,
size_t number_of_elements,
PretenureFlag pretenure) {
Handle<JSTypedArray> obj = NewJSTypedArray(elements_kind, pretenure);
+ DCHECK_EQ(obj->GetInternalFieldCount(),
+ v8::ArrayBufferView::kInternalFieldCount);
+ for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
+ obj->SetInternalField(i, Smi::kZero);
+ }
size_t element_size = GetFixedTypedArraysElementSize(elements_kind);
ExternalArrayType array_type = GetArrayTypeFromElementsKind(elements_kind);
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698