| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 static MaybeObject* Builtin_##name( \ | 146 static MaybeObject* Builtin_##name( \ |
| 147 int args_length, Object** args_object, Isolate* isolate) { \ | 147 int args_length, Object** args_object, Isolate* isolate) { \ |
| 148 name##ArgumentsType args(args_length, args_object); \ | 148 name##ArgumentsType args(args_length, args_object); \ |
| 149 return Builtin_impl##name(args, isolate); \ | 149 return Builtin_impl##name(args, isolate); \ |
| 150 } \ | 150 } \ |
| 151 static MaybeObject* Builtin_impl##name( \ | 151 static MaybeObject* Builtin_impl##name( \ |
| 152 name##ArgumentsType args, Isolate* isolate) | 152 name##ArgumentsType args, Isolate* isolate) |
| 153 #endif | 153 #endif |
| 154 | 154 |
| 155 | 155 |
| 156 #ifdef DEBUG |
| 156 static inline bool CalledAsConstructor(Isolate* isolate) { | 157 static inline bool CalledAsConstructor(Isolate* isolate) { |
| 157 #ifdef DEBUG | |
| 158 // Calculate the result using a full stack frame iterator and check | 158 // Calculate the result using a full stack frame iterator and check |
| 159 // that the state of the stack is as we assume it to be in the | 159 // that the state of the stack is as we assume it to be in the |
| 160 // code below. | 160 // code below. |
| 161 StackFrameIterator it(isolate); | 161 StackFrameIterator it(isolate); |
| 162 ASSERT(it.frame()->is_exit()); | 162 ASSERT(it.frame()->is_exit()); |
| 163 it.Advance(); | 163 it.Advance(); |
| 164 StackFrame* frame = it.frame(); | 164 StackFrame* frame = it.frame(); |
| 165 bool reference_result = frame->is_construct(); | 165 bool reference_result = frame->is_construct(); |
| 166 #endif | |
| 167 Address fp = Isolate::c_entry_fp(isolate->thread_local_top()); | 166 Address fp = Isolate::c_entry_fp(isolate->thread_local_top()); |
| 168 // Because we know fp points to an exit frame we can use the relevant | 167 // Because we know fp points to an exit frame we can use the relevant |
| 169 // part of ExitFrame::ComputeCallerState directly. | 168 // part of ExitFrame::ComputeCallerState directly. |
| 170 const int kCallerOffset = ExitFrameConstants::kCallerFPOffset; | 169 const int kCallerOffset = ExitFrameConstants::kCallerFPOffset; |
| 171 Address caller_fp = Memory::Address_at(fp + kCallerOffset); | 170 Address caller_fp = Memory::Address_at(fp + kCallerOffset); |
| 172 // This inlines the part of StackFrame::ComputeType that grabs the | 171 // This inlines the part of StackFrame::ComputeType that grabs the |
| 173 // type of the current frame. Note that StackFrame::ComputeType | 172 // type of the current frame. Note that StackFrame::ComputeType |
| 174 // has been specialized for each architecture so if any one of them | 173 // has been specialized for each architecture so if any one of them |
| 175 // changes this code has to be changed as well. | 174 // changes this code has to be changed as well. |
| 176 const int kMarkerOffset = StandardFrameConstants::kMarkerOffset; | 175 const int kMarkerOffset = StandardFrameConstants::kMarkerOffset; |
| 177 const Smi* kConstructMarker = Smi::FromInt(StackFrame::CONSTRUCT); | 176 const Smi* kConstructMarker = Smi::FromInt(StackFrame::CONSTRUCT); |
| 178 Object* marker = Memory::Object_at(caller_fp + kMarkerOffset); | 177 Object* marker = Memory::Object_at(caller_fp + kMarkerOffset); |
| 179 bool result = (marker == kConstructMarker); | 178 bool result = (marker == kConstructMarker); |
| 180 ASSERT_EQ(result, reference_result); | 179 ASSERT_EQ(result, reference_result); |
| 181 return result; | 180 return result; |
| 182 } | 181 } |
| 182 #endif |
| 183 | 183 |
| 184 | 184 |
| 185 // ---------------------------------------------------------------------------- | 185 // ---------------------------------------------------------------------------- |
| 186 | 186 |
| 187 BUILTIN(Illegal) { | 187 BUILTIN(Illegal) { |
| 188 UNREACHABLE(); | 188 UNREACHABLE(); |
| 189 return isolate->heap()->undefined_value(); // Make compiler happy. | 189 return isolate->heap()->undefined_value(); // Make compiler happy. |
| 190 } | 190 } |
| 191 | 191 |
| 192 | 192 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // IncrementalMarking. | 269 // IncrementalMarking. |
| 270 int size_delta = to_trim * entry_size; | 270 int size_delta = to_trim * entry_size; |
| 271 if (heap->marking()->TransferMark(elms->address(), | 271 if (heap->marking()->TransferMark(elms->address(), |
| 272 elms->address() + size_delta)) { | 272 elms->address() + size_delta)) { |
| 273 MemoryChunk::IncrementLiveBytesFromMutator(elms->address(), -size_delta); | 273 MemoryChunk::IncrementLiveBytesFromMutator(elms->address(), -size_delta); |
| 274 } | 274 } |
| 275 | 275 |
| 276 FixedArrayBase* new_elms = FixedArrayBase::cast(HeapObject::FromAddress( | 276 FixedArrayBase* new_elms = FixedArrayBase::cast(HeapObject::FromAddress( |
| 277 elms->address() + size_delta)); | 277 elms->address() + size_delta)); |
| 278 HeapProfiler* profiler = heap->isolate()->heap_profiler(); | 278 HeapProfiler* profiler = heap->isolate()->heap_profiler(); |
| 279 if (profiler->is_profiling()) { | 279 if (profiler->is_tracking_object_moves()) { |
| 280 profiler->ObjectMoveEvent(elms->address(), | 280 profiler->ObjectMoveEvent(elms->address(), |
| 281 new_elms->address(), | 281 new_elms->address(), |
| 282 new_elms->Size()); | 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 } | 283 } |
| 289 return new_elms; | 284 return new_elms; |
| 290 } | 285 } |
| 291 | 286 |
| 292 | 287 |
| 293 static bool ArrayPrototypeHasNoElements(Heap* heap, | 288 static bool ArrayPrototypeHasNoElements(Heap* heap, |
| 294 Context* native_context, | 289 Context* native_context, |
| 295 JSObject* array_proto) { | 290 JSObject* array_proto) { |
| 296 // This method depends on non writability of Object and Array prototype | 291 // This method depends on non writability of Object and Array prototype |
| 297 // fields. | 292 // fields. |
| 298 if (array_proto->elements() != heap->empty_fixed_array()) return false; | 293 if (array_proto->elements() != heap->empty_fixed_array()) return false; |
| 299 // Object.prototype | 294 // Object.prototype |
| 300 Object* proto = array_proto->GetPrototype(); | 295 Object* proto = array_proto->GetPrototype(); |
| 301 if (proto == heap->null_value()) return false; | 296 if (proto == heap->null_value()) return false; |
| 302 array_proto = JSObject::cast(proto); | 297 array_proto = JSObject::cast(proto); |
| 303 if (array_proto != native_context->initial_object_prototype()) return false; | 298 if (array_proto != native_context->initial_object_prototype()) return false; |
| 304 if (array_proto->elements() != heap->empty_fixed_array()) return false; | 299 if (array_proto->elements() != heap->empty_fixed_array()) return false; |
| 305 return array_proto->GetPrototype()->IsNull(); | 300 return array_proto->GetPrototype()->IsNull(); |
| 306 } | 301 } |
| 307 | 302 |
| 308 | 303 |
| 309 MUST_USE_RESULT | 304 MUST_USE_RESULT |
| 310 static inline MaybeObject* EnsureJSArrayWithWritableFastElements( | 305 static inline MaybeObject* EnsureJSArrayWithWritableFastElements( |
| 311 Heap* heap, Object* receiver, Arguments* args, int first_added_arg) { | 306 Heap* heap, Object* receiver, Arguments* args, int first_added_arg) { |
| 312 if (!receiver->IsJSArray()) return NULL; | 307 if (!receiver->IsJSArray()) return NULL; |
| 313 JSArray* array = JSArray::cast(receiver); | 308 JSArray* array = JSArray::cast(receiver); |
| 314 if (array->map()->is_observed()) return NULL; | 309 if (array->map()->is_observed()) return NULL; |
| 310 if (!array->map()->is_extensible()) return NULL; |
| 315 HeapObject* elms = array->elements(); | 311 HeapObject* elms = array->elements(); |
| 316 Map* map = elms->map(); | 312 Map* map = elms->map(); |
| 317 if (map == heap->fixed_array_map()) { | 313 if (map == heap->fixed_array_map()) { |
| 318 if (args == NULL || array->HasFastObjectElements()) return elms; | 314 if (args == NULL || array->HasFastObjectElements()) return elms; |
| 319 } else if (map == heap->fixed_cow_array_map()) { | 315 } else if (map == heap->fixed_cow_array_map()) { |
| 320 MaybeObject* maybe_writable_result = array->EnsureWritableFastElements(); | 316 MaybeObject* maybe_writable_result = array->EnsureWritableFastElements(); |
| 321 if (args == NULL || array->HasFastObjectElements() || | 317 if (args == NULL || array->HasFastObjectElements() || |
| 322 !maybe_writable_result->To(&elms)) { | 318 !maybe_writable_result->To(&elms)) { |
| 323 return maybe_writable_result; | 319 return maybe_writable_result; |
| 324 } | 320 } |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 static void Generate_KeyedLoadIC_NonStrictArguments(MacroAssembler* masm) { | 1374 static void Generate_KeyedLoadIC_NonStrictArguments(MacroAssembler* masm) { |
| 1379 KeyedLoadIC::GenerateNonStrictArguments(masm); | 1375 KeyedLoadIC::GenerateNonStrictArguments(masm); |
| 1380 } | 1376 } |
| 1381 | 1377 |
| 1382 | 1378 |
| 1383 static void Generate_StoreIC_Slow(MacroAssembler* masm) { | 1379 static void Generate_StoreIC_Slow(MacroAssembler* masm) { |
| 1384 StoreIC::GenerateSlow(masm); | 1380 StoreIC::GenerateSlow(masm); |
| 1385 } | 1381 } |
| 1386 | 1382 |
| 1387 | 1383 |
| 1388 static void Generate_StoreIC_Slow_Strict(MacroAssembler* masm) { | |
| 1389 StoreIC::GenerateSlow(masm); | |
| 1390 } | |
| 1391 | |
| 1392 | |
| 1393 static void Generate_StoreIC_Initialize(MacroAssembler* masm) { | 1384 static void Generate_StoreIC_Initialize(MacroAssembler* masm) { |
| 1394 StoreIC::GenerateInitialize(masm); | 1385 StoreIC::GenerateInitialize(masm); |
| 1395 } | 1386 } |
| 1396 | 1387 |
| 1397 | 1388 |
| 1398 static void Generate_StoreIC_Initialize_Strict(MacroAssembler* masm) { | 1389 static void Generate_StoreIC_Initialize_Strict(MacroAssembler* masm) { |
| 1399 StoreIC::GenerateInitialize(masm); | 1390 StoreIC::GenerateInitialize(masm); |
| 1400 } | 1391 } |
| 1401 | 1392 |
| 1402 | 1393 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1413 static void Generate_StoreIC_Miss(MacroAssembler* masm) { | 1404 static void Generate_StoreIC_Miss(MacroAssembler* masm) { |
| 1414 StoreIC::GenerateMiss(masm); | 1405 StoreIC::GenerateMiss(masm); |
| 1415 } | 1406 } |
| 1416 | 1407 |
| 1417 | 1408 |
| 1418 static void Generate_StoreIC_Normal(MacroAssembler* masm) { | 1409 static void Generate_StoreIC_Normal(MacroAssembler* masm) { |
| 1419 StoreIC::GenerateNormal(masm); | 1410 StoreIC::GenerateNormal(masm); |
| 1420 } | 1411 } |
| 1421 | 1412 |
| 1422 | 1413 |
| 1423 static void Generate_StoreIC_Normal_Strict(MacroAssembler* masm) { | |
| 1424 StoreIC::GenerateNormal(masm); | |
| 1425 } | |
| 1426 | |
| 1427 | |
| 1428 static void Generate_StoreIC_Megamorphic(MacroAssembler* masm) { | 1414 static void Generate_StoreIC_Megamorphic(MacroAssembler* masm) { |
| 1429 StoreIC::GenerateMegamorphic(masm, kNonStrictMode); | 1415 StoreIC::GenerateMegamorphic(masm, |
| 1416 StoreIC::ComputeExtraICState(kNonStrictMode)); |
| 1430 } | 1417 } |
| 1431 | 1418 |
| 1432 | 1419 |
| 1433 static void Generate_StoreIC_Megamorphic_Strict(MacroAssembler* masm) { | 1420 static void Generate_StoreIC_Megamorphic_Strict(MacroAssembler* masm) { |
| 1434 StoreIC::GenerateMegamorphic(masm, kStrictMode); | 1421 StoreIC::GenerateMegamorphic(masm, |
| 1422 StoreIC::ComputeExtraICState(kStrictMode)); |
| 1435 } | 1423 } |
| 1436 | 1424 |
| 1437 | 1425 |
| 1438 static void Generate_StoreIC_GlobalProxy(MacroAssembler* masm) { | |
| 1439 StoreIC::GenerateRuntimeSetProperty(masm, kNonStrictMode); | |
| 1440 } | |
| 1441 | |
| 1442 | |
| 1443 static void Generate_StoreIC_GlobalProxy_Strict(MacroAssembler* masm) { | |
| 1444 StoreIC::GenerateRuntimeSetProperty(masm, kStrictMode); | |
| 1445 } | |
| 1446 | |
| 1447 | |
| 1448 static void Generate_StoreIC_Setter_ForDeopt(MacroAssembler* masm) { | 1426 static void Generate_StoreIC_Setter_ForDeopt(MacroAssembler* masm) { |
| 1449 StoreStubCompiler::GenerateStoreViaSetter(masm, Handle<JSFunction>()); | 1427 StoreStubCompiler::GenerateStoreViaSetter(masm, Handle<JSFunction>()); |
| 1450 } | 1428 } |
| 1451 | 1429 |
| 1452 | 1430 |
| 1453 static void Generate_StoreIC_Generic(MacroAssembler* masm) { | 1431 static void Generate_StoreIC_Generic(MacroAssembler* masm) { |
| 1454 StoreIC::GenerateRuntimeSetProperty(masm, kNonStrictMode); | 1432 StoreIC::GenerateRuntimeSetProperty(masm, kNonStrictMode); |
| 1455 } | 1433 } |
| 1456 | 1434 |
| 1457 | 1435 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1473 static void Generate_KeyedStoreIC_Miss(MacroAssembler* masm) { | 1451 static void Generate_KeyedStoreIC_Miss(MacroAssembler* masm) { |
| 1474 KeyedStoreIC::GenerateMiss(masm); | 1452 KeyedStoreIC::GenerateMiss(masm); |
| 1475 } | 1453 } |
| 1476 | 1454 |
| 1477 | 1455 |
| 1478 static void Generate_KeyedStoreIC_Slow(MacroAssembler* masm) { | 1456 static void Generate_KeyedStoreIC_Slow(MacroAssembler* masm) { |
| 1479 KeyedStoreIC::GenerateSlow(masm); | 1457 KeyedStoreIC::GenerateSlow(masm); |
| 1480 } | 1458 } |
| 1481 | 1459 |
| 1482 | 1460 |
| 1483 static void Generate_KeyedStoreIC_Slow_Strict(MacroAssembler* masm) { | |
| 1484 KeyedStoreIC::GenerateSlow(masm); | |
| 1485 } | |
| 1486 | |
| 1487 | |
| 1488 static void Generate_KeyedStoreIC_Initialize(MacroAssembler* masm) { | 1461 static void Generate_KeyedStoreIC_Initialize(MacroAssembler* masm) { |
| 1489 KeyedStoreIC::GenerateInitialize(masm); | 1462 KeyedStoreIC::GenerateInitialize(masm); |
| 1490 } | 1463 } |
| 1491 | 1464 |
| 1492 | 1465 |
| 1493 static void Generate_KeyedStoreIC_Initialize_Strict(MacroAssembler* masm) { | 1466 static void Generate_KeyedStoreIC_Initialize_Strict(MacroAssembler* masm) { |
| 1494 KeyedStoreIC::GenerateInitialize(masm); | 1467 KeyedStoreIC::GenerateInitialize(masm); |
| 1495 } | 1468 } |
| 1496 | 1469 |
| 1497 | 1470 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 functions->generator = FUNCTION_ADDR(Generate_##aname); \ | 1633 functions->generator = FUNCTION_ADDR(Generate_##aname); \ |
| 1661 functions->c_code = NULL; \ | 1634 functions->c_code = NULL; \ |
| 1662 functions->s_name = #aname; \ | 1635 functions->s_name = #aname; \ |
| 1663 functions->name = k##aname; \ | 1636 functions->name = k##aname; \ |
| 1664 functions->flags = Code::ComputeFlags(Code::kind, \ | 1637 functions->flags = Code::ComputeFlags(Code::kind, \ |
| 1665 state, \ | 1638 state, \ |
| 1666 extra); \ | 1639 extra); \ |
| 1667 functions->extra_args = NO_EXTRA_ARGUMENTS; \ | 1640 functions->extra_args = NO_EXTRA_ARGUMENTS; \ |
| 1668 ++functions; | 1641 ++functions; |
| 1669 | 1642 |
| 1670 #define DEF_FUNCTION_PTR_H(aname, kind, extra) \ | 1643 #define DEF_FUNCTION_PTR_H(aname, kind) \ |
| 1671 functions->generator = FUNCTION_ADDR(Generate_##aname); \ | 1644 functions->generator = FUNCTION_ADDR(Generate_##aname); \ |
| 1672 functions->c_code = NULL; \ | 1645 functions->c_code = NULL; \ |
| 1673 functions->s_name = #aname; \ | 1646 functions->s_name = #aname; \ |
| 1674 functions->name = k##aname; \ | 1647 functions->name = k##aname; \ |
| 1675 functions->flags = Code::ComputeFlags( \ | 1648 functions->flags = Code::ComputeFlags( \ |
| 1676 Code::HANDLER, MONOMORPHIC, extra, Code::NORMAL, Code::kind); \ | 1649 Code::HANDLER, MONOMORPHIC, kNoExtraICState, \ |
| 1650 Code::NORMAL, Code::kind); \ |
| 1677 functions->extra_args = NO_EXTRA_ARGUMENTS; \ | 1651 functions->extra_args = NO_EXTRA_ARGUMENTS; \ |
| 1678 ++functions; | 1652 ++functions; |
| 1679 | 1653 |
| 1680 BUILTIN_LIST_C(DEF_FUNCTION_PTR_C) | 1654 BUILTIN_LIST_C(DEF_FUNCTION_PTR_C) |
| 1681 BUILTIN_LIST_A(DEF_FUNCTION_PTR_A) | 1655 BUILTIN_LIST_A(DEF_FUNCTION_PTR_A) |
| 1682 BUILTIN_LIST_H(DEF_FUNCTION_PTR_H) | 1656 BUILTIN_LIST_H(DEF_FUNCTION_PTR_H) |
| 1683 BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A) | 1657 BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A) |
| 1684 | 1658 |
| 1685 #undef DEF_FUNCTION_PTR_C | 1659 #undef DEF_FUNCTION_PTR_C |
| 1686 #undef DEF_FUNCTION_PTR_A | 1660 #undef DEF_FUNCTION_PTR_A |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 Code** code_address = \ | 1772 Code** code_address = \ |
| 1799 reinterpret_cast<Code**>(builtin_address(k##name)); \ | 1773 reinterpret_cast<Code**>(builtin_address(k##name)); \ |
| 1800 return Handle<Code>(code_address); \ | 1774 return Handle<Code>(code_address); \ |
| 1801 } | 1775 } |
| 1802 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \ | 1776 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \ |
| 1803 Handle<Code> Builtins::name() { \ | 1777 Handle<Code> Builtins::name() { \ |
| 1804 Code** code_address = \ | 1778 Code** code_address = \ |
| 1805 reinterpret_cast<Code**>(builtin_address(k##name)); \ | 1779 reinterpret_cast<Code**>(builtin_address(k##name)); \ |
| 1806 return Handle<Code>(code_address); \ | 1780 return Handle<Code>(code_address); \ |
| 1807 } | 1781 } |
| 1808 #define DEFINE_BUILTIN_ACCESSOR_H(name, kind, extra) \ | 1782 #define DEFINE_BUILTIN_ACCESSOR_H(name, kind) \ |
| 1809 Handle<Code> Builtins::name() { \ | 1783 Handle<Code> Builtins::name() { \ |
| 1810 Code** code_address = \ | 1784 Code** code_address = \ |
| 1811 reinterpret_cast<Code**>(builtin_address(k##name)); \ | 1785 reinterpret_cast<Code**>(builtin_address(k##name)); \ |
| 1812 return Handle<Code>(code_address); \ | 1786 return Handle<Code>(code_address); \ |
| 1813 } | 1787 } |
| 1814 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1788 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 1815 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1789 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 1816 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 1790 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 1817 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1791 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 1818 #undef DEFINE_BUILTIN_ACCESSOR_C | 1792 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 1819 #undef DEFINE_BUILTIN_ACCESSOR_A | 1793 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 1820 | 1794 |
| 1821 | 1795 |
| 1822 } } // namespace v8::internal | 1796 } } // namespace v8::internal |
| OLD | NEW |