Avoid convertion to double when it is not needed.
R=rossberg@chromium.org Review URL: https://codereview.chromium.org/15162002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14664 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
68eb1e50ca
commit
5889699ecf
@ -266,10 +266,12 @@ class Factory {
|
|||||||
PretenureFlag pretenure = NOT_TENURED);
|
PretenureFlag pretenure = NOT_TENURED);
|
||||||
Handle<Object> NewNumberFromUint(uint32_t value,
|
Handle<Object> NewNumberFromUint(uint32_t value,
|
||||||
PretenureFlag pretenure = NOT_TENURED);
|
PretenureFlag pretenure = NOT_TENURED);
|
||||||
|
inline Handle<Object> NewNumberFromSize(size_t value,
|
||||||
|
PretenureFlag pretenure = NOT_TENURED);
|
||||||
Handle<HeapNumber> NewHeapNumber(double value,
|
Handle<HeapNumber> NewHeapNumber(double value,
|
||||||
PretenureFlag pretenure = NOT_TENURED);
|
PretenureFlag pretenure = NOT_TENURED);
|
||||||
|
|
||||||
|
|
||||||
// These objects are used by the api to create env-independent data
|
// These objects are used by the api to create env-independent data
|
||||||
// structures in the heap.
|
// structures in the heap.
|
||||||
Handle<JSObject> NewNeanderObject();
|
Handle<JSObject> NewNeanderObject();
|
||||||
@ -539,6 +541,18 @@ class Factory {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
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
|
} } // namespace v8::internal
|
||||||
|
|
||||||
#endif // V8_FACTORY_H_
|
#endif // V8_FACTORY_H_
|
||||||
|
@ -857,9 +857,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) {
|
|||||||
ASSERT(byte_length % elementSize == 0);
|
ASSERT(byte_length % elementSize == 0);
|
||||||
size_t length = byte_length / elementSize;
|
size_t length = byte_length / elementSize;
|
||||||
|
|
||||||
Handle<Object> length_obj =
|
Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length);
|
||||||
isolate->factory()->NewNumber(static_cast<double>(length));
|
|
||||||
holder->set_length(*length_obj);
|
holder->set_length(*length_obj);
|
||||||
|
|
||||||
Handle<ExternalArray> elements =
|
Handle<ExternalArray> elements =
|
||||||
isolate->factory()->NewExternalArray(
|
isolate->factory()->NewExternalArray(
|
||||||
static_cast<int>(length), arrayType,
|
static_cast<int>(length), arrayType,
|
||||||
|
Loading…
Reference in New Issue
Block a user