| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 17 matching lines...) Expand all Loading... |
| 28 // Review notes: | 28 // Review notes: |
| 29 // | 29 // |
| 30 // - The use of macros in these inline functions may seem superfluous | 30 // - The use of macros in these inline functions may seem superfluous |
| 31 // but it is absolutely needed to make sure gcc generates optimal | 31 // but it is absolutely needed to make sure gcc generates optimal |
| 32 // code. gcc is not happy when attempting to inline too deep. | 32 // code. gcc is not happy when attempting to inline too deep. |
| 33 // | 33 // |
| 34 | 34 |
| 35 #ifndef V8_OBJECTS_INL_H_ | 35 #ifndef V8_OBJECTS_INL_H_ |
| 36 #define V8_OBJECTS_INL_H_ | 36 #define V8_OBJECTS_INL_H_ |
| 37 | 37 |
| 38 #include "objects.h" | 38 #include "memory.h" |
| 39 #include "contexts.h" | 39 #include "contexts.h" |
| 40 #include "conversions-inl.h" | 40 #include "conversions-inl.h" |
| 41 #include "objects.h" |
| 41 #include "property.h" | 42 #include "property.h" |
| 42 | 43 |
| 43 namespace v8 { | 44 namespace v8 { |
| 44 namespace internal { | 45 namespace internal { |
| 45 | 46 |
| 46 PropertyDetails::PropertyDetails(Smi* smi) { | 47 PropertyDetails::PropertyDetails(Smi* smi) { |
| 47 value_ = smi->value(); | 48 value_ = smi->value(); |
| 48 } | 49 } |
| 49 | 50 |
| 50 | 51 |
| (...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2395 HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize); | 2396 HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize); |
| 2396 // GetCodeFromTargetAddress might be called when marking objects during mark | 2397 // GetCodeFromTargetAddress might be called when marking objects during mark |
| 2397 // sweep. reinterpret_cast is therefore used instead of the more appropriate | 2398 // sweep. reinterpret_cast is therefore used instead of the more appropriate |
| 2398 // Code::cast. Code::cast does not work when the object's map is | 2399 // Code::cast. Code::cast does not work when the object's map is |
| 2399 // marked. | 2400 // marked. |
| 2400 Code* result = reinterpret_cast<Code*>(code); | 2401 Code* result = reinterpret_cast<Code*>(code); |
| 2401 return result; | 2402 return result; |
| 2402 } | 2403 } |
| 2403 | 2404 |
| 2404 | 2405 |
| 2406 Object* Code::GetObjectFromEntryAddress(Address location_of_address) { |
| 2407 return HeapObject:: |
| 2408 FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize); |
| 2409 } |
| 2410 |
| 2411 |
| 2405 Object* Map::prototype() { | 2412 Object* Map::prototype() { |
| 2406 return READ_FIELD(this, kPrototypeOffset); | 2413 return READ_FIELD(this, kPrototypeOffset); |
| 2407 } | 2414 } |
| 2408 | 2415 |
| 2409 | 2416 |
| 2410 void Map::set_prototype(Object* value, WriteBarrierMode mode) { | 2417 void Map::set_prototype(Object* value, WriteBarrierMode mode) { |
| 2411 ASSERT(value->IsNull() || value->IsJSObject()); | 2418 ASSERT(value->IsNull() || value->IsJSObject()); |
| 2412 WRITE_FIELD(this, kPrototypeOffset, value); | 2419 WRITE_FIELD(this, kPrototypeOffset, value); |
| 2413 CONDITIONAL_WRITE_BARRIER(this, kPrototypeOffset, mode); | 2420 CONDITIONAL_WRITE_BARRIER(this, kPrototypeOffset, mode); |
| 2414 } | 2421 } |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2724 ((code_age & kCodeAgeMask) << kCodeAgeShift)); | 2731 ((code_age & kCodeAgeMask) << kCodeAgeShift)); |
| 2725 } | 2732 } |
| 2726 | 2733 |
| 2727 | 2734 |
| 2728 bool JSFunction::IsBuiltin() { | 2735 bool JSFunction::IsBuiltin() { |
| 2729 return context()->global()->IsJSBuiltinsObject(); | 2736 return context()->global()->IsJSBuiltinsObject(); |
| 2730 } | 2737 } |
| 2731 | 2738 |
| 2732 | 2739 |
| 2733 Code* JSFunction::code() { | 2740 Code* JSFunction::code() { |
| 2734 return Code::cast(READ_FIELD(this, kCodeOffset)); | 2741 return Code::cast(unchecked_code()); |
| 2735 } | 2742 } |
| 2736 | 2743 |
| 2737 | 2744 |
| 2738 Code* JSFunction::unchecked_code() { | 2745 Code* JSFunction::unchecked_code() { |
| 2739 return reinterpret_cast<Code*>(READ_FIELD(this, kCodeOffset)); | 2746 return reinterpret_cast<Code*>( |
| 2747 Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset))); |
| 2740 } | 2748 } |
| 2741 | 2749 |
| 2742 | 2750 |
| 2743 void JSFunction::set_code(Code* value) { | 2751 void JSFunction::set_code(Code* value) { |
| 2744 // Skip the write barrier because code is never in new space. | 2752 // Skip the write barrier because code is never in new space. |
| 2745 ASSERT(!Heap::InNewSpace(value)); | 2753 ASSERT(!Heap::InNewSpace(value)); |
| 2746 WRITE_FIELD(this, kCodeOffset, value); | 2754 Address entry = value->entry(); |
| 2755 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); |
| 2747 } | 2756 } |
| 2748 | 2757 |
| 2749 | 2758 |
| 2750 Context* JSFunction::context() { | 2759 Context* JSFunction::context() { |
| 2751 return Context::cast(READ_FIELD(this, kContextOffset)); | 2760 return Context::cast(READ_FIELD(this, kContextOffset)); |
| 2752 } | 2761 } |
| 2753 | 2762 |
| 2754 | 2763 |
| 2755 Object* JSFunction::unchecked_context() { | 2764 Object* JSFunction::unchecked_context() { |
| 2756 return READ_FIELD(this, kContextOffset); | 2765 return READ_FIELD(this, kContextOffset); |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3449 #undef WRITE_INT_FIELD | 3458 #undef WRITE_INT_FIELD |
| 3450 #undef READ_SHORT_FIELD | 3459 #undef READ_SHORT_FIELD |
| 3451 #undef WRITE_SHORT_FIELD | 3460 #undef WRITE_SHORT_FIELD |
| 3452 #undef READ_BYTE_FIELD | 3461 #undef READ_BYTE_FIELD |
| 3453 #undef WRITE_BYTE_FIELD | 3462 #undef WRITE_BYTE_FIELD |
| 3454 | 3463 |
| 3455 | 3464 |
| 3456 } } // namespace v8::internal | 3465 } } // namespace v8::internal |
| 3457 | 3466 |
| 3458 #endif // V8_OBJECTS_INL_H_ | 3467 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |