CELL_SPACE, // Only and all cell objects.
PROPERTY_CELL_SPACE, // Only and all global property cell objects.
LO_SPACE, // Promoted large objects.
- INVALID_SPACE, // Only used in AllocationResult to signal success.
FIRST_SPACE = NEW_SPACE,
LAST_SPACE = LO_SPACE,
case PROPERTY_CELL_SPACE:
case LO_SPACE:
return false;
- case INVALID_SPACE:
- break;
}
UNREACHABLE();
return false;
return property_cell_space_->Contains(addr);
case LO_SPACE:
return lo_space_->SlowContains(addr);
- case INVALID_SPACE:
- break;
}
UNREACHABLE();
return false;
public:
// Implicit constructor from Object*.
AllocationResult(Object* object) // NOLINT
- : object_(object),
- retry_space_(INVALID_SPACE) {}
+ : object_(object) {
+ // AllocationResults can't return Smis, which are used to represent
+ // failure and the space to retry in.
+ CHECK(!object->IsSmi());
+ }
- AllocationResult() : object_(NULL), retry_space_(INVALID_SPACE) {}
+ AllocationResult() : object_(Smi::FromInt(NEW_SPACE)) {}
static inline AllocationResult Retry(AllocationSpace space = NEW_SPACE) {
return AllocationResult(space);
}
- inline bool IsRetry() { return retry_space_ != INVALID_SPACE; }
+ inline bool IsRetry() { return object_->IsSmi(); }
template <typename T>
bool To(T** obj) {
AllocationSpace RetrySpace() {
DCHECK(IsRetry());
- return retry_space_;
+ return static_cast<AllocationSpace>(Smi::cast(object_)->value());
}
private:
explicit AllocationResult(AllocationSpace space)
- : object_(NULL), retry_space_(space) {}
+ : object_(Smi::FromInt(static_cast<int>(space))) {}
Object* object_;
- AllocationSpace retry_space_;
};
+STATIC_ASSERT(sizeof(AllocationResult) == kPointerSize);
+
+
class PagedSpace : public Space {
public:
// Creates a space with a maximum capacity, and an id.
}
}
UNREACHABLE();
- return INVALID_SPACE;
+ return FIRST_SPACE;
}
// No reservation for large object space necessary.
static const int kNumberOfPreallocatedSpaces = LO_SPACE;
- static const int kNumberOfSpaces = INVALID_SPACE;
+ static const int kNumberOfSpaces = LAST_SPACE + 1;
protected:
// Where the pointed-to object can be found:
Builtins::kIllegal)).ToObjectChecked();
// Return success.
- return Smi::FromInt(42);
+ return heap->true_value();
}
v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate());
env->Enter();
Handle<Object> o = Test();
- CHECK(o->IsSmi() && Smi::cast(*o)->value() == 42);
+ CHECK(o->IsTrue());
env->Exit();
}
// Call the accessor through JavaScript.
v8::Handle<v8::Value> result = v8::Script::Compile(
v8::String::NewFromUtf8(CcTest::isolate(), "(new Foo).get"))->Run();
- CHECK_EQ(42, result->Int32Value());
+ CHECK_EQ(true, result->BooleanValue());
env->Exit();
}