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

Issue 652041: IA32: Native access to TranscendentalCache for sin/cos. (Closed)

Created:
10 years, 10 months ago by Lasse Reichstein
Modified:
9 years, 6 months ago
Reviewers:
fschneider
CC:
v8-dev
Visibility:
Public.

Description

IA32: Native access to TranscendentalCache for sin/cos.

Patch Set 1 #

Patch Set 2 : Updated to head. Removed dead code. Ignore first patch. #

Total comments: 15
Unified diffs Side-by-side diffs Delta from patch set Stats (+384 lines, -5 lines) Patch
M src/arm/codegen-arm.h View 1 1 chunk +4 lines, -0 lines 0 comments Download
M src/arm/codegen-arm.cc View 1 1 chunk +18 lines, -0 lines 0 comments Download
M src/assembler.h View 1 chunk +1 line, -0 lines 0 comments Download
M src/assembler.cc View 1 chunk +5 lines, -0 lines 0 comments Download
M src/code-stubs.h View 1 chunk +1 line, -0 lines 0 comments Download
M src/codegen.cc View 1 1 chunk +2 lines, -0 lines 0 comments Download
M src/heap.h View 1 3 chunks +13 lines, -0 lines 0 comments Download
M src/ia32/assembler-ia32.h View 2 chunks +4 lines, -0 lines 0 comments Download
M src/ia32/assembler-ia32.cc View 3 chunks +23 lines, -0 lines 0 comments Download
M src/ia32/codegen-ia32.h View 1 2 chunks +20 lines, -0 lines 0 comments Download
M src/ia32/codegen-ia32.cc View 1 2 chunks +228 lines, -0 lines 13 comments Download
M src/ia32/disasm-ia32.cc View 2 chunks +3 lines, -1 line 2 comments Download
M src/math.js View 2 chunks +2 lines, -2 lines 0 comments Download
M src/runtime.cc View 1 15 chunks +15 lines, -0 lines 0 comments Download
M src/serialize.cc View 1 chunk +4 lines, -0 lines 0 comments Download
M src/v8-counters.h View 1 chunk +18 lines, -1 line 0 comments Download
M src/x64/codegen-x64.h View 1 1 chunk +5 lines, -1 line 0 comments Download
M src/x64/codegen-x64.cc View 1 1 chunk +18 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
Lasse Reichstein
IA32-only optimization for review.
10 years, 10 months ago (2010-02-22 10:36:39 UTC) #1
fschneider
http://codereview.chromium.org/652041/diff/19/1027 File src/ia32/codegen-ia32.cc (right): http://codereview.chromium.org/652041/diff/19/1027#newcode8174 src/ia32/codegen-ia32.cc:8174: __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); Just an idea: Could you optimize ...
10 years, 10 months ago (2010-02-22 17:42:54 UTC) #2
Lasse Reichstein
10 years, 10 months ago (2010-02-23 10:18:53 UTC) #3
http://codereview.chromium.org/652041/diff/19/1027
File src/ia32/codegen-ia32.cc (right):

http://codereview.chromium.org/652041/diff/19/1027#newcode8174
src/ia32/codegen-ia32.cc:8174: __ fld_d(FieldOperand(eax,
HeapNumber::kValueOffset));
Probably. I would need a flag, or two different paths, to know whether I should
load the double value later. I would also need to remember the pointer to the
heap number (which I can otherwise drop after these loads).
In any case, fld is a very cheap operation (for the CPU, it just onloads it on
the FPU and waits for it to complete there). I don't think it's worth
complicating the code for.

http://codereview.chromium.org/652041/diff/19/1027#newcode8192
src/ia32/codegen-ia32.cc:8192: __ and_(Operand(ecx),
Immediate(TranscendentalCache::kCacheSize - 1));
Well spotted. I moved this line up here but forgot the assert.

http://codereview.chromium.org/652041/diff/19/1027#newcode8228
src/ia32/codegen-ia32.cc:8228: __ cmp(edx, Operand(ecx, kIntSize));  // NOLINT
It should be. The cache element holds two integers, which together should be all
the bits of the double.
The kIntSize here matches the layout test in the DEBUG section above.
The NOLINT should go, in any case. It no longer reads sizeof(int32_t).

http://codereview.chromium.org/652041/diff/19/1027#newcode8232
src/ia32/codegen-ia32.cc:8232: __ fstp(0);
I don't think it's worth it.
In the smi case, I need to convert the smi to a double, so the fldi does double
service by both converting and pushing the value. The fstp operation is very
quick as well (often just 1 cycle on modern chips).

http://codereview.chromium.org/652041/diff/19/1027#newcode8271
src/ia32/codegen-ia32.cc:8271: case TranscendentalCache::COS: {
There are potentially more, some of which won't need the same setup as the 2PI
periodic ones, but there's no need for the generality yet. I'll make it into an
ASSERT and make a comment about future extensions.

http://codereview.chromium.org/652041/diff/19/1027#newcode8320
src/ia32/codegen-ia32.cc:8320: __ fprem();
It is slightly slower on some chips, but it also gives a slightly more precise
result. I guess the tradeof should go in the direction of precission in this
case. I'll change it to fprem1.

http://codereview.chromium.org/652041/diff/19/1029
File src/ia32/disasm-ia32.cc (right):

http://codereview.chromium.org/652041/diff/19/1029#newcode681
src/ia32/disasm-ia32.cc:681: case 0: mnem = "fld_`d"; break;
fixed.

Powered by Google App Engine
This is Rietveld 408576698