| Index: src/objects-inl.h
|
| ===================================================================
|
| --- src/objects-inl.h (revision 5316)
|
| +++ src/objects-inl.h (working copy)
|
| @@ -35,9 +35,10 @@
|
| #ifndef V8_OBJECTS_INL_H_
|
| #define V8_OBJECTS_INL_H_
|
|
|
| -#include "objects.h"
|
| +#include "memory.h"
|
| #include "contexts.h"
|
| #include "conversions-inl.h"
|
| +#include "objects.h"
|
| #include "property.h"
|
|
|
| namespace v8 {
|
| @@ -2111,20 +2112,28 @@
|
|
|
|
|
| int HeapObject::SizeFromMap(Map* map) {
|
| - InstanceType instance_type = map->instance_type();
|
| + int instance_size = map->instance_size();
|
| + if (instance_size != kVariableSizeSentinel) return instance_size;
|
| + // We can ignore the "symbol" bit becase it is only set for symbols
|
| + // and implies a string type.
|
| + int instance_type = static_cast<int>(map->instance_type()) & ~kIsSymbolMask;
|
| // Only inline the most frequent cases.
|
| - if (instance_type == JS_OBJECT_TYPE ||
|
| - (instance_type & (kIsNotStringMask | kStringRepresentationMask)) ==
|
| - (kStringTag | kConsStringTag) ||
|
| - instance_type == JS_ARRAY_TYPE) return map->instance_size();
|
| if (instance_type == FIXED_ARRAY_TYPE) {
|
| return FixedArray::BodyDescriptor::SizeOf(map, this);
|
| }
|
| + if (instance_type == ASCII_STRING_TYPE) {
|
| + return SeqAsciiString::SizeFor(
|
| + reinterpret_cast<SeqAsciiString*>(this)->length());
|
| + }
|
| if (instance_type == BYTE_ARRAY_TYPE) {
|
| return reinterpret_cast<ByteArray*>(this)->ByteArraySize();
|
| }
|
| - // Otherwise do the general size computation.
|
| - return SlowSizeFromMap(map);
|
| + if (instance_type == STRING_TYPE) {
|
| + return SeqTwoByteString::SizeFor(
|
| + reinterpret_cast<SeqTwoByteString*>(this)->length());
|
| + }
|
| + ASSERT(instance_type == CODE_TYPE);
|
| + return reinterpret_cast<Code*>(this)->CodeSize();
|
| }
|
|
|
|
|
| @@ -2402,6 +2411,12 @@
|
| }
|
|
|
|
|
| +Object* Code::GetObjectFromEntryAddress(Address location_of_address) {
|
| + return HeapObject::
|
| + FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize);
|
| +}
|
| +
|
| +
|
| Object* Map::prototype() {
|
| return READ_FIELD(this, kPrototypeOffset);
|
| }
|
| @@ -2731,19 +2746,21 @@
|
|
|
|
|
| Code* JSFunction::code() {
|
| - return Code::cast(READ_FIELD(this, kCodeOffset));
|
| + return Code::cast(unchecked_code());
|
| }
|
|
|
|
|
| Code* JSFunction::unchecked_code() {
|
| - return reinterpret_cast<Code*>(READ_FIELD(this, kCodeOffset));
|
| + return reinterpret_cast<Code*>(
|
| + Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset)));
|
| }
|
|
|
|
|
| void JSFunction::set_code(Code* value) {
|
| // Skip the write barrier because code is never in new space.
|
| ASSERT(!Heap::InNewSpace(value));
|
| - WRITE_FIELD(this, kCodeOffset, value);
|
| + Address entry = value->entry();
|
| + WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry));
|
| }
|
|
|
|
|
|
|