PretenureFlag pretenure = NOT_TENURED);
Handle<Object> NewNumberFromUint(uint32_t value,
PretenureFlag pretenure = NOT_TENURED);
-
+ inline Handle<Object> NewNumberFromSize(size_t value,
+ PretenureFlag pretenure = NOT_TENURED);
Handle<HeapNumber> NewHeapNumber(double value,
PretenureFlag pretenure = NOT_TENURED);
+
// These objects are used by the api to create env-independent data
// structures in the heap.
Handle<JSObject> NewNeanderObject();
};
+Handle<Object> Factory::NewNumberFromSize(size_t value,
+ PretenureFlag pretenure) {
+ if (Smi::IsValid(static_cast<intptr_t>(value))) {
+ return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)),
+ isolate());
+ } else {
+ return NewNumber(static_cast<double>(value), pretenure);
+ }
+}
+
+
+
} } // namespace v8::internal
#endif // V8_FACTORY_H_
ASSERT(byte_length % elementSize == 0);
size_t length = byte_length / elementSize;
- Handle<Object> length_obj =
- isolate->factory()->NewNumber(static_cast<double>(length));
+ Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length);
holder->set_length(*length_obj);
+
Handle<ExternalArray> elements =
isolate->factory()->NewExternalArray(
static_cast<int>(length), arrayType,