Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: src/runtime/runtime-maths.cc

Issue 866553003: Allocate typed array for rempio2 result. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: make runtime call slightly faster. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/runtime/runtime-maths.cc
diff --git a/src/runtime/runtime-maths.cc b/src/runtime/runtime-maths.cc
index 6397ad15de9aaedff245e09a3c1356a701ace8c1..3e02e424db1816bf067e12bae77dd182126b855a 100644
--- a/src/runtime/runtime-maths.cc
+++ b/src/runtime/runtime-maths.cc
@@ -60,19 +60,16 @@ RUNTIME_FUNCTION(Runtime_ConstructDouble) {
RUNTIME_FUNCTION(Runtime_RemPiO2) {
- HandleScope handle_scope(isolate);
- DCHECK(args.length() == 1);
+ SealHandleScope shs(isolate);
+ DisallowHeapAllocation no_gc;
+ DCHECK(args.length() == 2);
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- Factory* factory = isolate->factory();
- double y[2] = {0.0, 0.0};
+ CONVERT_ARG_CHECKED(JSTypedArray, result, 1);
+ RUNTIME_ASSERT(result->byte_length() == Smi::FromInt(2 * sizeof(double)));
+ void* backing_store = JSArrayBuffer::cast(result->buffer())->backing_store();
+ double* y = reinterpret_cast<double*>(backing_store);
Sven Panne 2015/02/06 07:37:28 A static_cast is enough here and a smaller sledgeh
int n = fdlibm::rempio2(x, y);
- Handle<FixedArray> array = factory->NewFixedArray(3);
- Handle<HeapNumber> y0 = factory->NewHeapNumber(y[0]);
- Handle<HeapNumber> y1 = factory->NewHeapNumber(y[1]);
- array->set(0, Smi::FromInt(n));
- array->set(1, *y0);
- array->set(2, *y1);
- return *factory->NewJSArrayWithElements(array);
+ return Smi::FromInt(n);
Sven Panne 2015/02/06 07:37:28 Just inline "n", its name is not that helpful, any
}

Powered by Google App Engine
This is Rietveld 408576698