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

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: addressed comments 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
« no previous file with comments | « src/runtime/runtime.h ('k') | src/third_party/fdlibm/fdlibm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-maths.cc
diff --git a/src/runtime/runtime-maths.cc b/src/runtime/runtime-maths.cc
index 6397ad15de9aaedff245e09a3c1356a701ace8c1..68dfa49af839abb99a6027e021a400e83f77f674 100644
--- a/src/runtime/runtime-maths.cc
+++ b/src/runtime/runtime-maths.cc
@@ -60,19 +60,15 @@ 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};
- 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);
+ 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 = static_cast<double*>(backing_store);
+ return Smi::FromInt(fdlibm::rempio2(x, y));
}
« no previous file with comments | « src/runtime/runtime.h ('k') | src/third_party/fdlibm/fdlibm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698