Revision f230a1cf deps/v8/src/builtins.cc
deps/v8/src/builtins.cc | ||
---|---|---|
195 | 195 |
} |
196 | 196 |
|
197 | 197 |
|
198 |
static MaybeObject* ArrayCodeGenericCommon(Arguments* args, |
|
199 |
Isolate* isolate, |
|
200 |
JSFunction* constructor) { |
|
201 |
ASSERT(args->length() >= 1); |
|
202 |
Heap* heap = isolate->heap(); |
|
203 |
isolate->counters()->array_function_runtime()->Increment(); |
|
204 |
|
|
205 |
JSArray* array; |
|
206 |
if (CalledAsConstructor(isolate)) { |
|
207 |
array = JSArray::cast((*args)[0]); |
|
208 |
// Initialize elements and length in case later allocations fail so that the |
|
209 |
// array object is initialized in a valid state. |
|
210 |
MaybeObject* maybe_array = array->Initialize(0); |
|
211 |
if (maybe_array->IsFailure()) return maybe_array; |
|
212 |
|
|
213 |
AllocationMemento* memento = AllocationMemento::FindForJSObject(array); |
|
214 |
if (memento != NULL && memento->IsValid()) { |
|
215 |
AllocationSite* site = memento->GetAllocationSite(); |
|
216 |
ElementsKind to_kind = site->GetElementsKind(); |
|
217 |
if (IsMoreGeneralElementsKindTransition(array->GetElementsKind(), |
|
218 |
to_kind)) { |
|
219 |
// We have advice that we should change the elements kind |
|
220 |
if (FLAG_trace_track_allocation_sites) { |
|
221 |
PrintF("AllocationSite: pre-transitioning array %p(%s->%s)\n", |
|
222 |
reinterpret_cast<void*>(array), |
|
223 |
ElementsKindToString(array->GetElementsKind()), |
|
224 |
ElementsKindToString(to_kind)); |
|
225 |
} |
|
226 |
|
|
227 |
maybe_array = array->TransitionElementsKind(to_kind); |
|
228 |
if (maybe_array->IsFailure()) return maybe_array; |
|
229 |
} |
|
230 |
} |
|
231 |
|
|
232 |
if (!FLAG_smi_only_arrays) { |
|
233 |
Context* native_context = isolate->context()->native_context(); |
|
234 |
if (array->GetElementsKind() == GetInitialFastElementsKind() && |
|
235 |
!native_context->js_array_maps()->IsUndefined()) { |
|
236 |
FixedArray* map_array = |
|
237 |
FixedArray::cast(native_context->js_array_maps()); |
|
238 |
array->set_map(Map::cast(map_array-> |
|
239 |
get(TERMINAL_FAST_ELEMENTS_KIND))); |
|
240 |
} |
|
241 |
} |
|
242 |
} else { |
|
243 |
// Allocate the JS Array |
|
244 |
MaybeObject* maybe_obj = heap->AllocateJSObject(constructor); |
|
245 |
if (!maybe_obj->To(&array)) return maybe_obj; |
|
246 |
} |
|
247 |
|
|
248 |
Arguments adjusted_arguments(args->length() - 1, args->arguments() - 1); |
|
249 |
ASSERT(adjusted_arguments.length() < 1 || |
|
250 |
adjusted_arguments[0] == (*args)[1]); |
|
251 |
return ArrayConstructInitializeElements(array, &adjusted_arguments); |
|
252 |
} |
|
253 |
|
|
254 |
|
|
255 |
BUILTIN(InternalArrayCodeGeneric) { |
|
256 |
return ArrayCodeGenericCommon( |
|
257 |
&args, |
|
258 |
isolate, |
|
259 |
isolate->context()->native_context()->internal_array_function()); |
|
260 |
} |
|
261 |
|
|
262 |
|
|
263 |
BUILTIN(ArrayCodeGeneric) { |
|
264 |
return ArrayCodeGenericCommon( |
|
265 |
&args, |
|
266 |
isolate, |
|
267 |
isolate->context()->native_context()->array_function()); |
|
268 |
} |
|
269 |
|
|
270 |
|
|
271 | 198 |
static void MoveDoubleElements(FixedDoubleArray* dst, |
272 | 199 |
int dst_index, |
273 | 200 |
FixedDoubleArray* src, |
... | ... | |
346 | 273 |
MemoryChunk::IncrementLiveBytesFromMutator(elms->address(), -size_delta); |
347 | 274 |
} |
348 | 275 |
|
349 |
HEAP_PROFILE(heap, ObjectMoveEvent(elms->address(), |
|
350 |
elms->address() + size_delta)); |
|
351 |
return FixedArrayBase::cast(HeapObject::FromAddress( |
|
352 |
elms->address() + to_trim * entry_size)); |
|
276 |
FixedArrayBase* new_elms = FixedArrayBase::cast(HeapObject::FromAddress( |
|
277 |
elms->address() + size_delta)); |
|
278 |
HeapProfiler* profiler = heap->isolate()->heap_profiler(); |
|
279 |
if (profiler->is_profiling()) { |
|
280 |
profiler->ObjectMoveEvent(elms->address(), |
|
281 |
new_elms->address(), |
|
282 |
new_elms->Size()); |
|
283 |
if (profiler->is_tracking_allocations()) { |
|
284 |
// Report filler object as a new allocation. |
|
285 |
// Otherwise it will become an untracked object. |
|
286 |
profiler->NewObjectEvent(elms->address(), elms->Size()); |
|
287 |
} |
|
288 |
} |
|
289 |
return new_elms; |
|
353 | 290 |
} |
354 | 291 |
|
355 | 292 |
|
... | ... | |
1392 | 1329 |
|
1393 | 1330 |
|
1394 | 1331 |
static void Generate_LoadIC_Getter_ForDeopt(MacroAssembler* masm) { |
1395 |
LoadStubCompiler::GenerateLoadViaGetter(masm, Handle<JSFunction>()); |
|
1332 |
LoadStubCompiler::GenerateLoadViaGetter( |
|
1333 |
masm, LoadStubCompiler::registers()[0], Handle<JSFunction>()); |
|
1396 | 1334 |
} |
1397 | 1335 |
|
1398 | 1336 |
|
... | ... | |
1451 | 1389 |
} |
1452 | 1390 |
|
1453 | 1391 |
|
1392 |
static void Generate_StoreIC_Slow_Strict(MacroAssembler* masm) { |
|
1393 |
StoreIC::GenerateSlow(masm); |
|
1394 |
} |
|
1395 |
|
|
1396 |
|
|
1454 | 1397 |
static void Generate_StoreIC_Initialize(MacroAssembler* masm) { |
1455 | 1398 |
StoreIC::GenerateInitialize(masm); |
1456 | 1399 |
} |
... | ... | |
1546 | 1489 |
} |
1547 | 1490 |
|
1548 | 1491 |
|
1492 |
static void Generate_KeyedStoreIC_Slow_Strict(MacroAssembler* masm) { |
|
1493 |
KeyedStoreIC::GenerateSlow(masm); |
|
1494 |
} |
|
1495 |
|
|
1496 |
|
|
1549 | 1497 |
static void Generate_KeyedStoreIC_Initialize(MacroAssembler* masm) { |
1550 | 1498 |
KeyedStoreIC::GenerateInitialize(masm); |
1551 | 1499 |
} |
... | ... | |
1728 | 1676 |
functions->extra_args = NO_EXTRA_ARGUMENTS; \ |
1729 | 1677 |
++functions; |
1730 | 1678 |
|
1679 |
#define DEF_FUNCTION_PTR_H(aname, kind, extra) \ |
|
1680 |
functions->generator = FUNCTION_ADDR(Generate_##aname); \ |
|
1681 |
functions->c_code = NULL; \ |
|
1682 |
functions->s_name = #aname; \ |
|
1683 |
functions->name = k##aname; \ |
|
1684 |
functions->flags = Code::ComputeFlags( \ |
|
1685 |
Code::HANDLER, MONOMORPHIC, extra, Code::NORMAL, Code::kind); \ |
|
1686 |
functions->extra_args = NO_EXTRA_ARGUMENTS; \ |
|
1687 |
++functions; |
|
1688 |
|
|
1731 | 1689 |
BUILTIN_LIST_C(DEF_FUNCTION_PTR_C) |
1732 | 1690 |
BUILTIN_LIST_A(DEF_FUNCTION_PTR_A) |
1691 |
BUILTIN_LIST_H(DEF_FUNCTION_PTR_H) |
|
1733 | 1692 |
BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A) |
1734 | 1693 |
|
1735 | 1694 |
#undef DEF_FUNCTION_PTR_C |
... | ... | |
1854 | 1813 |
reinterpret_cast<Code**>(builtin_address(k##name)); \ |
1855 | 1814 |
return Handle<Code>(code_address); \ |
1856 | 1815 |
} |
1816 |
#define DEFINE_BUILTIN_ACCESSOR_H(name, kind, extra) \ |
|
1817 |
Handle<Code> Builtins::name() { \ |
|
1818 |
Code** code_address = \ |
|
1819 |
reinterpret_cast<Code**>(builtin_address(k##name)); \ |
|
1820 |
return Handle<Code>(code_address); \ |
|
1821 |
} |
|
1857 | 1822 |
BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
1858 | 1823 |
BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
1824 |
BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
|
1859 | 1825 |
BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
1860 | 1826 |
#undef DEFINE_BUILTIN_ACCESSOR_C |
1861 | 1827 |
#undef DEFINE_BUILTIN_ACCESSOR_A |
Also available in: Unified diff