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

Side by Side Diff: src/runtime/runtime-literals.cc

Issue 2126613002: making heap verification more aggressive (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding additional validation Created 4 years, 5 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') | src/runtime/runtime-regexp.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 JSObject::MigrateSlowToFast(boilerplate, 107 JSObject::MigrateSlowToFast(boilerplate,
108 boilerplate->map()->unused_property_fields(), 108 boilerplate->map()->unused_property_fields(),
109 "FastLiteral"); 109 "FastLiteral");
110 } 110 }
111 return boilerplate; 111 return boilerplate;
112 } 112 }
113 113
114 static MaybeHandle<Object> CreateArrayLiteralBoilerplate( 114 static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
115 Isolate* isolate, Handle<LiteralsArray> literals, 115 Isolate* isolate, Handle<LiteralsArray> literals,
116 Handle<FixedArray> elements) { 116 Handle<FixedArray> elements) {
117 // Create the JSArray.
118 Handle<JSFunction> constructor = isolate->array_function();
119
120 PretenureFlag pretenure_flag =
121 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED;
122
123 Handle<JSArray> object = Handle<JSArray>::cast(
124 isolate->factory()->NewJSObject(constructor, pretenure_flag));
125
126 ElementsKind constant_elements_kind = 117 ElementsKind constant_elements_kind =
127 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value()); 118 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value());
119 DCHECK(IsFastElementsKind(constant_elements_kind));
128 Handle<FixedArrayBase> constant_elements_values( 120 Handle<FixedArrayBase> constant_elements_values(
129 FixedArrayBase::cast(elements->get(1))); 121 FixedArrayBase::cast(elements->get(1)));
122 Handle<FixedArrayBase> copied_elements_values;
130 123
131 {
132 DisallowHeapAllocation no_gc;
133 DCHECK(IsFastElementsKind(constant_elements_kind));
134 Context* native_context = isolate->context()->native_context();
135 Object* map =
136 native_context->get(Context::ArrayMapIndex(constant_elements_kind));
137 object->set_map(Map::cast(map));
138 }
139
140 Handle<FixedArrayBase> copied_elements_values;
141 if (IsFastDoubleElementsKind(constant_elements_kind)) { 124 if (IsFastDoubleElementsKind(constant_elements_kind)) {
142 copied_elements_values = isolate->factory()->CopyFixedDoubleArray( 125 copied_elements_values = isolate->factory()->CopyFixedDoubleArray(
143 Handle<FixedDoubleArray>::cast(constant_elements_values)); 126 Handle<FixedDoubleArray>::cast(constant_elements_values));
144 } else { 127 } else {
145 DCHECK(IsFastSmiOrObjectElementsKind(constant_elements_kind)); 128 DCHECK(IsFastSmiOrObjectElementsKind(constant_elements_kind));
146 const bool is_cow = (constant_elements_values->map() == 129 const bool is_cow = (constant_elements_values->map() ==
147 isolate->heap()->fixed_cow_array_map()); 130 isolate->heap()->fixed_cow_array_map());
148 if (is_cow) { 131 if (is_cow) {
149 copied_elements_values = constant_elements_values; 132 copied_elements_values = constant_elements_values;
150 #if DEBUG 133 #if DEBUG
(...skipping 18 matching lines...) Expand all
169 FixedArray::cast(fixed_array_values->get(i))); 152 FixedArray::cast(fixed_array_values->get(i)));
170 Handle<Object> result; 153 Handle<Object> result;
171 ASSIGN_RETURN_ON_EXCEPTION( 154 ASSIGN_RETURN_ON_EXCEPTION(
172 isolate, result, 155 isolate, result,
173 CreateLiteralBoilerplate(isolate, literals, fa), Object); 156 CreateLiteralBoilerplate(isolate, literals, fa), Object);
174 fixed_array_values_copy->set(i, *result); 157 fixed_array_values_copy->set(i, *result);
175 } 158 }
176 }); 159 });
177 } 160 }
178 } 161 }
179 object->set_elements(*copied_elements_values); 162 // Create the JSArray.
180 object->set_length(Smi::FromInt(copied_elements_values->length())); 163 PretenureFlag pretenure_flag =
181 164 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED;
165 Handle<JSArray> object = isolate->factory()->NewJSArrayWithElements(
166 copied_elements_values, constant_elements_kind,
167 copied_elements_values->length(), pretenure_flag);
182 JSObject::ValidateElements(object); 168 JSObject::ValidateElements(object);
183 return object; 169 return object;
184 } 170 }
185 171
186 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( 172 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate(
187 Isolate* isolate, Handle<LiteralsArray> literals, 173 Isolate* isolate, Handle<LiteralsArray> literals,
188 Handle<FixedArray> array) { 174 Handle<FixedArray> array) {
189 Handle<FixedArray> elements = CompileTimeValue::GetElements(array); 175 Handle<FixedArray> elements = CompileTimeValue::GetElements(array);
190 switch (CompileTimeValue::GetLiteralType(array)) { 176 switch (CompileTimeValue::GetLiteralType(array)) {
191 case CompileTimeValue::OBJECT_LITERAL_FAST_ELEMENTS: 177 case CompileTimeValue::OBJECT_LITERAL_FAST_ELEMENTS:
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 333
348 Handle<LiteralsArray> literals(closure->literals(), isolate); 334 Handle<LiteralsArray> literals(closure->literals(), isolate);
349 RETURN_RESULT_OR_FAILURE( 335 RETURN_RESULT_OR_FAILURE(
350 isolate, 336 isolate,
351 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, 337 CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
352 ArrayLiteral::kShallowElements)); 338 ArrayLiteral::kShallowElements));
353 } 339 }
354 340
355 } // namespace internal 341 } // namespace internal
356 } // namespace v8 342 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/runtime/runtime-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698