therubyracer 0.6.3 → 0.7.0.pre
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of therubyracer might be problematic. Click here for more details.
- data/Rakefile +10 -9
- data/ext/v8/callbacks.cpp +15 -8
- data/ext/v8/converters.cpp +7 -8
- data/ext/v8/converters.h +0 -2
- data/ext/v8/extconf.rb +2 -0
- data/ext/v8/rr.cpp +169 -0
- data/ext/v8/rr.h +34 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/AUTHORS +8 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/ChangeLog +198 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/LICENSE +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/SConstruct +152 -38
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/include/v8-debug.h +52 -4
- data/ext/v8/upstream/2.1.10/include/v8-profiler.h +176 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/include/v8.h +227 -48
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/SConscript +60 -10
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/accessors.cc +5 -39
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/accessors.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/allocation.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/allocation.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/api.cc +477 -57
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/api.h +8 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/apinatives.js +1 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/apiutils.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arguments.h +5 -6
- data/ext/v8/upstream/{2.0.6/src/arm/assembler-thumb2-inl.h → 2.1.10/src/arm/assembler-arm-inl.h} +42 -27
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/assembler-arm.cc +430 -216
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/assembler-arm.h +199 -110
- data/ext/v8/upstream/{2.0.6/src/arm/assembler-arm-inl.h → 2.1.10/src/arm/assembler-thumb2-inl.h} +4 -18
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/assembler-thumb2.cc +142 -85
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/assembler-thumb2.h +18 -9
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/builtins-arm.cc +127 -87
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/codegen-arm-inl.h +3 -5
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/codegen-arm.cc +4634 -1427
- data/ext/v8/upstream/2.1.10/src/arm/codegen-arm.h +946 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/constants-arm.cc +21 -3
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/constants-arm.h +39 -13
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/cpu-arm.cc +9 -3
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/debug-arm.cc +34 -8
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/disasm-arm.cc +262 -117
- data/ext/v8/upstream/2.1.10/src/arm/fast-codegen-arm.cc +238 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/frames-arm.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/frames-arm.h +0 -0
- data/ext/v8/upstream/{2.0.6/src/arm/fast-codegen-arm.cc → 2.1.10/src/arm/full-codegen-arm.cc} +453 -283
- data/ext/v8/upstream/2.1.10/src/arm/ic-arm.cc +1833 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/jump-target-arm.cc +3 -29
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/macro-assembler-arm.cc +564 -104
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/macro-assembler-arm.h +255 -46
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/regexp-macro-assembler-arm.cc +78 -104
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/regexp-macro-assembler-arm.h +6 -22
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/register-allocator-arm-inl.h +0 -3
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/register-allocator-arm.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/register-allocator-arm.h +2 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/simulator-arm.cc +557 -180
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/simulator-arm.h +52 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/stub-cache-arm.cc +904 -240
- data/ext/v8/upstream/2.1.10/src/arm/virtual-frame-arm.cc +668 -0
- data/ext/v8/upstream/2.1.10/src/arm/virtual-frame-arm.h +503 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/array.js +82 -109
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/assembler.cc +49 -13
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/assembler.h +27 -5
- data/ext/v8/upstream/2.1.10/src/ast.cc +1138 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ast.h +354 -53
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/bootstrapper.cc +609 -501
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/bootstrapper.h +27 -8
- data/ext/v8/upstream/2.1.10/src/builtins.cc +1512 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/builtins.h +41 -25
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/bytecodes-irregexp.h +0 -0
- data/ext/v8/upstream/2.1.10/src/cached-powers.h +119 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/char-predicates-inl.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/char-predicates.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/checks.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/checks.h +25 -1
- data/ext/v8/upstream/2.1.10/src/circular-queue-inl.h +101 -0
- data/ext/v8/upstream/2.1.10/src/circular-queue.cc +121 -0
- data/ext/v8/upstream/2.1.10/src/circular-queue.h +129 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/code-stubs.cc +23 -8
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/code-stubs.h +16 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/code.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/codegen-inl.h +6 -34
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/codegen.cc +73 -92
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/codegen.h +164 -68
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/compilation-cache.cc +117 -73
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/compilation-cache.h +18 -17
- data/ext/v8/upstream/2.1.10/src/compiler.cc +623 -0
- data/ext/v8/upstream/2.1.10/src/compiler.h +299 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/contexts.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/contexts.h +8 -11
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/conversions-inl.h +28 -13
- data/ext/v8/upstream/2.1.10/src/conversions.cc +1105 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/conversions.h +9 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/counters.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/counters.h +1 -1
- data/ext/v8/upstream/2.1.10/src/cpu-profiler-inl.h +99 -0
- data/ext/v8/upstream/2.1.10/src/cpu-profiler.cc +494 -0
- data/ext/v8/upstream/2.1.10/src/cpu-profiler.h +277 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/cpu.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8-debug.cc +15 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8-debug.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8-posix.cc +18 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8-readline.cc +2 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8-windows.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8.cc +10 -6
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8.h +2 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8.js +43 -38
- data/ext/v8/upstream/2.1.10/src/data-flow.cc +755 -0
- data/ext/v8/upstream/2.1.10/src/data-flow.h +278 -0
- data/ext/v8/upstream/{2.0.6/src/date-delay.js → 2.1.10/src/date.js} +100 -110
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/dateparser-inl.h +11 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/dateparser.cc +24 -26
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/dateparser.h +8 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/debug-agent.cc +3 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/debug-agent.h +0 -0
- data/ext/v8/upstream/{2.0.6/src/debug-delay.js → 2.1.10/src/debug-debugger.js} +111 -15
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/debug.cc +156 -96
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/debug.h +53 -5
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/disasm.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/disassembler.cc +2 -8
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/disassembler.h +0 -0
- data/ext/v8/upstream/2.1.10/src/diy-fp.cc +58 -0
- data/ext/v8/upstream/2.1.10/src/diy-fp.h +117 -0
- data/ext/v8/upstream/2.1.10/src/double.h +169 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/dtoa-config.c +4 -3
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/execution.cc +22 -22
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/execution.h +17 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/factory.cc +70 -46
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/factory.h +27 -17
- data/ext/v8/upstream/2.1.10/src/fast-codegen.cc +746 -0
- data/ext/v8/upstream/2.1.10/src/fast-codegen.h +161 -0
- data/ext/v8/upstream/2.1.10/src/fast-dtoa.cc +512 -0
- data/ext/v8/upstream/2.1.10/src/fast-dtoa.h +59 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/flag-definitions.h +32 -11
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/flags.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/flags.h +0 -0
- data/ext/v8/upstream/2.1.10/src/flow-graph.cc +763 -0
- data/ext/v8/upstream/2.1.10/src/flow-graph.h +180 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/frame-element.cc +1 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/frame-element.h +49 -11
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/frames-inl.h +2 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/frames.cc +91 -17
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/frames.h +24 -2
- data/ext/v8/upstream/{2.0.6/src/fast-codegen.cc → 2.1.10/src/full-codegen.cc} +549 -198
- data/ext/v8/upstream/{2.0.6/src/fast-codegen.h → 2.1.10/src/full-codegen.h} +109 -29
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/func-name-inferrer.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/func-name-inferrer.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/global-handles.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/global-handles.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/globals.h +67 -43
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/handles-inl.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/handles.cc +124 -129
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/handles.h +33 -15
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/hashmap.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/hashmap.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/heap-inl.h +56 -12
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/heap-profiler.cc +2 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/heap-profiler.h +2 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/heap.cc +413 -221
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/heap.h +192 -67
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/assembler-ia32-inl.h +6 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/assembler-ia32.cc +187 -32
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/assembler-ia32.h +31 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/builtins-ia32.cc +160 -133
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/codegen-ia32-inl.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/codegen-ia32.cc +5533 -2177
- data/ext/v8/upstream/{2.0.6/src/x64/codegen-x64.h → 2.1.10/src/ia32/codegen-ia32.h} +453 -134
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/cpu-ia32.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/debug-ia32.cc +63 -8
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/disasm-ia32.cc +99 -16
- data/ext/v8/upstream/2.1.10/src/ia32/fast-codegen-ia32.cc +950 -0
- data/ext/v8/upstream/2.1.10/src/ia32/fast-codegen-ia32.h +155 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/frames-ia32.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/frames-ia32.h +0 -0
- data/ext/v8/upstream/{2.0.6/src/ia32/fast-codegen-ia32.cc → 2.1.10/src/ia32/full-codegen-ia32.cc} +454 -253
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/ic-ia32.cc +545 -390
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/jump-target-ia32.cc +1 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/macro-assembler-ia32.cc +330 -139
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/macro-assembler-ia32.h +96 -30
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/regexp-macro-assembler-ia32.cc +73 -89
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/regexp-macro-assembler-ia32.h +6 -21
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/register-allocator-ia32-inl.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/register-allocator-ia32.cc +59 -5
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/register-allocator-ia32.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/simulator-ia32.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/simulator-ia32.h +2 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/stub-cache-ia32.cc +745 -303
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/virtual-frame-ia32.cc +278 -71
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/virtual-frame-ia32.h +78 -22
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ic-inl.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ic.cc +172 -89
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ic.h +51 -20
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/interpreter-irregexp.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/interpreter-irregexp.h +0 -0
- data/ext/v8/upstream/{2.0.6/src/json-delay.js → 2.1.10/src/json.js} +26 -12
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/jsregexp.cc +151 -118
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/jsregexp.h +31 -7
- data/ext/v8/upstream/2.1.10/src/jump-target-heavy-inl.h +51 -0
- data/ext/v8/upstream/{2.0.6/src/jump-target.cc → 2.1.10/src/jump-target-heavy.cc} +164 -184
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/jump-target-inl.h +8 -9
- data/ext/v8/upstream/{2.0.6/src/usage-analyzer.h → 2.1.10/src/jump-target-light-inl.h} +9 -7
- data/ext/v8/upstream/2.1.10/src/jump-target-light.cc +86 -0
- data/ext/v8/upstream/2.1.10/src/jump-target.cc +155 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/jump-target.h +6 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/list-inl.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/list.h +2 -1
- data/ext/v8/upstream/2.1.10/src/liveedit-debugger.js +944 -0
- data/ext/v8/upstream/2.1.10/src/liveedit.cc +1468 -0
- data/ext/v8/upstream/2.1.10/src/liveedit.h +170 -0
- data/ext/v8/upstream/2.1.10/src/log-inl.h +59 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/log-utils.cc +3 -9
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/log-utils.h +1 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/log.cc +198 -95
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/log.h +50 -49
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/macro-assembler.h +9 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/macros.py +30 -11
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/mark-compact.cc +464 -152
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/mark-compact.h +41 -20
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/math.js +9 -8
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/memory.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/messages.cc +1 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/messages.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/messages.js +46 -9
- data/ext/v8/upstream/2.1.10/src/mips/assembler-mips-inl.h +215 -0
- data/ext/v8/upstream/2.1.10/src/mips/assembler-mips.cc +1208 -0
- data/ext/v8/upstream/2.1.10/src/mips/assembler-mips.h +665 -0
- data/ext/v8/upstream/2.1.10/src/mips/builtins-mips.cc +202 -0
- data/ext/v8/upstream/2.1.10/src/mips/codegen-mips-inl.h +70 -0
- data/ext/v8/upstream/2.1.10/src/mips/codegen-mips.cc +1428 -0
- data/ext/v8/upstream/{2.0.6/src/arm/codegen-arm.h → 2.1.10/src/mips/codegen-mips.h} +103 -205
- data/ext/v8/upstream/2.1.10/src/mips/constants-mips.cc +323 -0
- data/ext/v8/upstream/2.1.10/src/mips/constants-mips.h +525 -0
- data/ext/v8/upstream/2.1.10/src/mips/cpu-mips.cc +69 -0
- data/ext/v8/upstream/2.1.10/src/mips/debug-mips.cc +128 -0
- data/ext/v8/upstream/2.1.10/src/mips/disasm-mips.cc +784 -0
- data/ext/v8/upstream/2.1.10/src/mips/fast-codegen-mips.cc +74 -0
- data/ext/v8/upstream/2.1.10/src/mips/frames-mips.cc +99 -0
- data/ext/v8/upstream/2.1.10/src/mips/frames-mips.h +164 -0
- data/ext/v8/upstream/2.1.10/src/mips/full-codegen-mips.cc +273 -0
- data/ext/v8/upstream/2.1.10/src/mips/ic-mips.cc +217 -0
- data/ext/v8/upstream/2.1.10/src/mips/jump-target-mips.cc +172 -0
- data/ext/v8/upstream/2.1.10/src/mips/macro-assembler-mips.cc +1323 -0
- data/ext/v8/upstream/2.1.10/src/mips/macro-assembler-mips.h +461 -0
- data/ext/v8/upstream/2.1.10/src/mips/register-allocator-mips-inl.h +137 -0
- data/ext/v8/upstream/2.1.10/src/mips/register-allocator-mips.cc +60 -0
- data/ext/v8/upstream/2.1.10/src/mips/register-allocator-mips.h +46 -0
- data/ext/v8/upstream/2.1.10/src/mips/simulator-mips.cc +1648 -0
- data/ext/v8/upstream/2.1.10/src/mips/simulator-mips.h +311 -0
- data/ext/v8/upstream/2.1.10/src/mips/stub-cache-mips.cc +400 -0
- data/ext/v8/upstream/2.1.10/src/mips/virtual-frame-mips.cc +316 -0
- data/ext/v8/upstream/{2.0.6/src/arm/virtual-frame-arm.h → 2.1.10/src/mips/virtual-frame-mips.h} +87 -71
- data/ext/v8/upstream/{2.0.6/src/mirror-delay.js → 2.1.10/src/mirror-debugger.js} +51 -45
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/mksnapshot.cc +97 -10
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/natives.h +6 -6
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/objects-debug.cc +47 -5
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/objects-inl.h +154 -38
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/objects.cc +528 -280
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/objects.h +302 -95
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/oprofile-agent.cc +25 -33
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/oprofile-agent.h +9 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/parser.cc +444 -72
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/parser.h +4 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-freebsd.cc +32 -13
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-linux.cc +59 -25
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-macos.cc +30 -13
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-nullos.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-openbsd.cc +21 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-posix.cc +0 -18
- data/ext/v8/upstream/2.1.10/src/platform-solaris.cc +607 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-win32.cc +16 -17
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform.h +25 -8
- data/ext/v8/upstream/2.1.10/src/powers-ten.h +2461 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/prettyprinter.cc +49 -29
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/prettyprinter.h +3 -1
- data/ext/v8/upstream/2.1.10/src/profile-generator-inl.h +124 -0
- data/ext/v8/upstream/2.1.10/src/profile-generator.cc +583 -0
- data/ext/v8/upstream/2.1.10/src/profile-generator.h +364 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/property.cc +1 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/property.h +12 -24
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler-irregexp-inl.h +2 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler-irregexp.cc +2 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler-irregexp.h +2 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler-tracer.cc +2 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler-tracer.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler.cc +33 -10
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler.h +12 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-stack.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-stack.h +0 -0
- data/ext/v8/upstream/{2.0.6/src/regexp-delay.js → 2.1.10/src/regexp.js} +180 -58
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/register-allocator-inl.h +68 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/register-allocator.cc +5 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/register-allocator.h +42 -17
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/rewriter.cc +110 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/rewriter.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/runtime.cc +2733 -623
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/runtime.h +43 -20
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/runtime.js +46 -35
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/scanner.cc +278 -36
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/scanner.h +97 -26
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/scopeinfo.cc +3 -3
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/scopeinfo.h +1 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/scopes.cc +11 -12
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/scopes.h +0 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/serialize.cc +298 -175
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/serialize.h +184 -40
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/shell.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/simulator.h +2 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/smart-pointer.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/snapshot-common.cc +16 -31
- data/ext/v8/upstream/2.1.10/src/snapshot-empty.cc +50 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/snapshot.h +13 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/spaces-inl.h +35 -27
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/spaces.cc +256 -42
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/spaces.h +136 -42
- data/ext/v8/upstream/{2.0.6/src/zone-inl.h → 2.1.10/src/splay-tree-inl.h} +102 -89
- data/ext/v8/upstream/2.1.10/src/splay-tree.h +203 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/string-stream.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/string-stream.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/string.js +260 -149
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/stub-cache.cc +195 -69
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/stub-cache.h +127 -12
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/third_party/dtoa/COPYING +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/third_party/dtoa/dtoa.c +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/third_party/valgrind/valgrind.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/token.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/token.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/top.cc +26 -31
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/top.h +3 -4
- data/ext/v8/upstream/2.1.10/src/type-info.cc +53 -0
- data/ext/v8/upstream/2.1.10/src/type-info.h +244 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/unicode-inl.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/unicode.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/unicode.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/uri.js +6 -6
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/utils.cc +0 -37
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/utils.h +121 -50
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8-counters.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8-counters.h +130 -98
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8.cc +42 -11
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8.h +4 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8natives.js +202 -37
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8threads.cc +11 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8threads.h +15 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/variables.cc +7 -51
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/variables.h +5 -35
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/version.cc +3 -3
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/version.h +0 -0
- data/ext/v8/upstream/2.1.10/src/virtual-frame-heavy-inl.h +152 -0
- data/ext/v8/upstream/{2.0.6/src/virtual-frame.cc → 2.1.10/src/virtual-frame-heavy.cc} +107 -176
- data/ext/v8/upstream/2.1.10/src/virtual-frame-inl.h +39 -0
- data/ext/v8/upstream/2.1.10/src/virtual-frame-light-inl.h +69 -0
- data/ext/v8/upstream/2.1.10/src/virtual-frame-light.cc +49 -0
- data/ext/v8/upstream/2.1.10/src/virtual-frame.cc +49 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/virtual-frame.h +2 -0
- data/ext/v8/upstream/{2.0.6/src/log-inl.h → 2.1.10/src/vm-state-inl.h} +28 -20
- data/ext/v8/upstream/{2.0.6/src/snapshot-empty.cc → 2.1.10/src/vm-state.cc} +5 -6
- data/ext/v8/upstream/2.1.10/src/vm-state.h +75 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/assembler-x64-inl.h +11 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/assembler-x64.cc +285 -93
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/assembler-x64.h +81 -78
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/builtins-x64.cc +130 -87
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/codegen-x64-inl.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/codegen-x64.cc +4520 -1317
- data/ext/v8/upstream/{2.0.6/src/ia32/codegen-ia32.h → 2.1.10/src/x64/codegen-x64.h} +362 -141
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/cpu-x64.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/debug-x64.cc +20 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/disasm-x64.cc +121 -44
- data/ext/v8/upstream/2.1.10/src/x64/fast-codegen-x64.cc +246 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/frames-x64.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/frames-x64.h +0 -0
- data/ext/v8/upstream/{2.0.6/src/x64/fast-codegen-x64.cc → 2.1.10/src/x64/full-codegen-x64.cc} +404 -231
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/ic-x64.cc +346 -117
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/jump-target-x64.cc +1 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/macro-assembler-x64.cc +537 -181
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/macro-assembler-x64.h +140 -34
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/regexp-macro-assembler-x64.cc +74 -96
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/regexp-macro-assembler-x64.h +8 -25
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/register-allocator-x64-inl.h +1 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/register-allocator-x64.cc +3 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/register-allocator-x64.h +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/simulator-x64.cc +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/simulator-x64.h +2 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/stub-cache-x64.cc +785 -288
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/virtual-frame-x64.cc +128 -52
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/virtual-frame-x64.h +40 -19
- data/ext/v8/upstream/2.1.10/src/zone-inl.h +82 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/zone.cc +1 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/zone.h +6 -90
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/codemap.js +12 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/consarray.js +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/csvparser.js +22 -37
- data/ext/v8/upstream/2.1.10/tools/generate-ten-powers.scm +286 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/gyp/v8.gyp +86 -24
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/js2c.py +22 -22
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/jsmin.py +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/linux-tick-processor +10 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/linux-tick-processor.py +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/logreader.js +34 -16
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/mac-nm +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/mac-tick-processor +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/annotate +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/common +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/dump +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/report +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/reset +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/run +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/shutdown +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/start +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/presubmit.py +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/process-heap-prof.py +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/profile.js +70 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/profile_view.js +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/run-valgrind.py +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/splaytree.js +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/splaytree.py +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/stats-viewer.py +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/test.py +7 -7
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/tickprocessor-driver.js +7 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/tickprocessor.js +140 -9
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/tickprocessor.py +40 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/utils.py +6 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/README.txt +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/arm.vsprops +1 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/common.vsprops +1 -2
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/d8.vcproj +0 -6
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/d8_arm.vcproj +193 -199
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/d8_x64.vcproj +16 -8
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/d8js2c.cmd +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/debug.vsprops +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/ia32.vsprops +5 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/js2c.cmd +1 -1
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/release.vsprops +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8.sln +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8.vcproj +11 -7
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_arm.sln +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_arm.vcproj +227 -223
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_base.vcproj +137 -5
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_base_arm.vcproj +116 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_base_x64.vcproj +125 -4
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_cctest.vcproj +12 -6
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_cctest_arm.vcproj +12 -6
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_cctest_x64.vcproj +11 -11
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_mksnapshot.vcproj +0 -6
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_mksnapshot_x64.vcproj +0 -6
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_process_sample.vcproj +0 -6
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_process_sample_arm.vcproj +145 -151
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_process_sample_x64.vcproj +16 -6
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_shell_sample.vcproj +0 -6
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_shell_sample_arm.vcproj +145 -151
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_shell_sample_x64.vcproj +16 -8
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_snapshot.vcproj +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_snapshot_cc.vcproj +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_snapshot_cc_x64.vcproj +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_snapshot_x64.vcproj +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_x64.sln +0 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_x64.vcproj +11 -7
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/x64.vsprops +5 -1
- data/ext/v8/upstream/2.1.10/tools/windows-tick-processor.bat +29 -0
- data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/windows-tick-processor.py +0 -0
- data/ext/v8/upstream/Makefile +8 -2
- data/ext/v8/v8.cpp +21 -73
- data/ext/v8/v8_array.cpp +56 -0
- data/ext/v8/v8_array.h +8 -0
- data/ext/v8/v8_callbacks.cpp +121 -0
- data/ext/v8/v8_callbacks.h +8 -0
- data/ext/v8/v8_cxt.cpp +74 -77
- data/ext/v8/v8_cxt.h +2 -9
- data/ext/v8/v8_date.cpp +26 -0
- data/ext/v8/v8_date.h +6 -0
- data/ext/v8/v8_exception.cpp +55 -0
- data/ext/v8/v8_exception.h +6 -0
- data/ext/v8/v8_external.cpp +50 -0
- data/ext/v8/v8_external.h +8 -0
- data/ext/v8/v8_func.cpp +76 -18
- data/ext/v8/v8_func.h +5 -4
- data/ext/v8/v8_msg.cpp +55 -46
- data/ext/v8/v8_msg.h +3 -11
- data/ext/v8/v8_obj.cpp +67 -36
- data/ext/v8/v8_obj.h +6 -8
- data/ext/v8/v8_ref.cpp +25 -9
- data/ext/v8/v8_ref.h +3 -5
- data/ext/v8/v8_script.cpp +17 -10
- data/ext/v8/v8_script.h +3 -3
- data/ext/v8/v8_str.cpp +34 -6
- data/ext/v8/v8_str.h +4 -2
- data/ext/v8/v8_template.cpp +195 -33
- data/ext/v8/v8_template.h +4 -5
- data/ext/v8/v8_try_catch.cpp +99 -0
- data/ext/v8/v8_try_catch.h +5 -0
- data/ext/v8/v8_value.cpp +164 -0
- data/ext/v8/v8_value.h +10 -0
- data/lib/v8.rb +3 -1
- data/lib/v8/access.rb +60 -0
- data/lib/v8/array.rb +15 -0
- data/lib/v8/callbacks.rb +88 -0
- data/lib/v8/cli.rb +1 -1
- data/lib/v8/context.rb +55 -66
- data/lib/v8/function.rb +20 -2
- data/lib/v8/object.rb +14 -12
- data/lib/v8/ruby_error.rb +3 -0
- data/lib/v8/to.rb +59 -7
- data/spec/ext/cxt_spec.rb +2 -15
- data/spec/ext/func_spec.rb +17 -10
- data/spec/ext/try_catch_spec.rb +32 -0
- data/spec/foo.rb +17 -0
- data/spec/redjs/jsapi_spec.rb +173 -96
- data/spec/spec_helper.rb +7 -0
- data/spec/v8/to_spec.rb +0 -1
- data/therubyracer.gemspec +6 -6
- metadata +493 -386
- data/ext/v8/upstream/2.0.6/src/arm/ic-arm.cc +0 -849
- data/ext/v8/upstream/2.0.6/src/arm/virtual-frame-arm.cc +0 -412
- data/ext/v8/upstream/2.0.6/src/ast.cc +0 -512
- data/ext/v8/upstream/2.0.6/src/builtins.cc +0 -851
- data/ext/v8/upstream/2.0.6/src/compiler.cc +0 -1132
- data/ext/v8/upstream/2.0.6/src/compiler.h +0 -107
- data/ext/v8/upstream/2.0.6/src/conversions.cc +0 -709
- data/ext/v8/upstream/2.0.6/src/usage-analyzer.cc +0 -426
- data/ext/v8/upstream/2.0.6/tools/windows-tick-processor.bat +0 -5
- data/ext/v8/upstream/no-strict-aliasing.patch +0 -13
- data/ext/v8/v8_standalone.cpp +0 -69
- data/ext/v8/v8_standalone.h +0 -31
- data/spec/ext/obj_spec.rb +0 -13
@@ -0,0 +1,299 @@
|
|
1
|
+
// Copyright 2006-2008 the V8 project authors. All rights reserved.
|
2
|
+
// Redistribution and use in source and binary forms, with or without
|
3
|
+
// modification, are permitted provided that the following conditions are
|
4
|
+
// met:
|
5
|
+
//
|
6
|
+
// * Redistributions of source code must retain the above copyright
|
7
|
+
// notice, this list of conditions and the following disclaimer.
|
8
|
+
// * Redistributions in binary form must reproduce the above
|
9
|
+
// copyright notice, this list of conditions and the following
|
10
|
+
// disclaimer in the documentation and/or other materials provided
|
11
|
+
// with the distribution.
|
12
|
+
// * Neither the name of Google Inc. nor the names of its
|
13
|
+
// contributors may be used to endorse or promote products derived
|
14
|
+
// from this software without specific prior written permission.
|
15
|
+
//
|
16
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
20
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
23
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
#ifndef V8_COMPILER_H_
|
29
|
+
#define V8_COMPILER_H_
|
30
|
+
|
31
|
+
#include "ast.h"
|
32
|
+
#include "frame-element.h"
|
33
|
+
#include "parser.h"
|
34
|
+
#include "register-allocator.h"
|
35
|
+
#include "zone.h"
|
36
|
+
|
37
|
+
namespace v8 {
|
38
|
+
namespace internal {
|
39
|
+
|
40
|
+
// CompilationInfo encapsulates some information known at compile time. It
|
41
|
+
// is constructed based on the resources available at compile-time.
|
42
|
+
class CompilationInfo BASE_EMBEDDED {
|
43
|
+
public:
|
44
|
+
// Compilation mode. Either the compiler is used as the primary
|
45
|
+
// compiler and needs to setup everything or the compiler is used as
|
46
|
+
// the secondary compiler for split compilation and has to handle
|
47
|
+
// bailouts.
|
48
|
+
enum Mode {
|
49
|
+
PRIMARY,
|
50
|
+
SECONDARY
|
51
|
+
};
|
52
|
+
|
53
|
+
// A description of the compilation state at a bailout to the secondary
|
54
|
+
// code generator.
|
55
|
+
//
|
56
|
+
// The state is currently simple: there are no parameters or local
|
57
|
+
// variables to worry about ('this' can be found in the stack frame).
|
58
|
+
// There are at most two live values.
|
59
|
+
//
|
60
|
+
// There is a label that should be bound to the beginning of the bailout
|
61
|
+
// stub code.
|
62
|
+
class Bailout : public ZoneObject {
|
63
|
+
public:
|
64
|
+
Bailout(Register left, Register right) : left_(left), right_(right) {}
|
65
|
+
|
66
|
+
Label* label() { return &label_; }
|
67
|
+
|
68
|
+
private:
|
69
|
+
Register left_;
|
70
|
+
Register right_;
|
71
|
+
Label label_;
|
72
|
+
};
|
73
|
+
|
74
|
+
|
75
|
+
// Lazy compilation of a JSFunction.
|
76
|
+
CompilationInfo(Handle<JSFunction> closure,
|
77
|
+
int loop_nesting,
|
78
|
+
Handle<Object> receiver)
|
79
|
+
: closure_(closure),
|
80
|
+
function_(NULL),
|
81
|
+
is_eval_(false),
|
82
|
+
loop_nesting_(loop_nesting),
|
83
|
+
receiver_(receiver) {
|
84
|
+
Initialize();
|
85
|
+
ASSERT(!closure_.is_null() &&
|
86
|
+
shared_info_.is_null() &&
|
87
|
+
script_.is_null());
|
88
|
+
}
|
89
|
+
|
90
|
+
// Lazy compilation based on SharedFunctionInfo.
|
91
|
+
explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info)
|
92
|
+
: shared_info_(shared_info),
|
93
|
+
function_(NULL),
|
94
|
+
is_eval_(false),
|
95
|
+
loop_nesting_(0) {
|
96
|
+
Initialize();
|
97
|
+
ASSERT(closure_.is_null() &&
|
98
|
+
!shared_info_.is_null() &&
|
99
|
+
script_.is_null());
|
100
|
+
}
|
101
|
+
|
102
|
+
// Eager compilation.
|
103
|
+
CompilationInfo(FunctionLiteral* literal, Handle<Script> script, bool is_eval)
|
104
|
+
: script_(script),
|
105
|
+
function_(literal),
|
106
|
+
is_eval_(is_eval),
|
107
|
+
loop_nesting_(0) {
|
108
|
+
Initialize();
|
109
|
+
ASSERT(closure_.is_null() &&
|
110
|
+
shared_info_.is_null() &&
|
111
|
+
!script_.is_null());
|
112
|
+
}
|
113
|
+
|
114
|
+
// We can only get a JSFunction if we actually have one.
|
115
|
+
Handle<JSFunction> closure() { return closure_; }
|
116
|
+
|
117
|
+
// We can get a SharedFunctionInfo from a JSFunction or if we actually
|
118
|
+
// have one.
|
119
|
+
Handle<SharedFunctionInfo> shared_info() {
|
120
|
+
if (!closure().is_null()) {
|
121
|
+
return Handle<SharedFunctionInfo>(closure()->shared());
|
122
|
+
} else {
|
123
|
+
return shared_info_;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
// We can always get a script. Either we have one or we can get a shared
|
128
|
+
// function info.
|
129
|
+
Handle<Script> script() {
|
130
|
+
if (!script_.is_null()) {
|
131
|
+
return script_;
|
132
|
+
} else {
|
133
|
+
ASSERT(shared_info()->script()->IsScript());
|
134
|
+
return Handle<Script>(Script::cast(shared_info()->script()));
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
// There should always be a function literal, but it may be set after
|
139
|
+
// construction (for lazy compilation).
|
140
|
+
FunctionLiteral* function() { return function_; }
|
141
|
+
void set_function(FunctionLiteral* literal) { function_ = literal; }
|
142
|
+
|
143
|
+
// Simple accessors.
|
144
|
+
bool is_eval() { return is_eval_; }
|
145
|
+
int loop_nesting() { return loop_nesting_; }
|
146
|
+
bool has_receiver() { return !receiver_.is_null(); }
|
147
|
+
Handle<Object> receiver() { return receiver_; }
|
148
|
+
List<Bailout*>* bailouts() { return &bailouts_; }
|
149
|
+
|
150
|
+
// Accessors for mutable fields (possibly set by analysis passes) with
|
151
|
+
// default values given by Initialize.
|
152
|
+
Mode mode() { return mode_; }
|
153
|
+
void set_mode(Mode mode) { mode_ = mode; }
|
154
|
+
|
155
|
+
bool has_this_properties() { return has_this_properties_; }
|
156
|
+
void set_has_this_properties(bool flag) { has_this_properties_ = flag; }
|
157
|
+
|
158
|
+
bool has_global_object() {
|
159
|
+
return !closure().is_null() && (closure()->context()->global() != NULL);
|
160
|
+
}
|
161
|
+
|
162
|
+
GlobalObject* global_object() {
|
163
|
+
return has_global_object() ? closure()->context()->global() : NULL;
|
164
|
+
}
|
165
|
+
|
166
|
+
bool has_globals() { return has_globals_; }
|
167
|
+
void set_has_globals(bool flag) { has_globals_ = flag; }
|
168
|
+
|
169
|
+
// Derived accessors.
|
170
|
+
Scope* scope() { return function()->scope(); }
|
171
|
+
|
172
|
+
// Add a bailout with two live values.
|
173
|
+
Label* AddBailout(Register left, Register right) {
|
174
|
+
Bailout* bailout = new Bailout(left, right);
|
175
|
+
bailouts_.Add(bailout);
|
176
|
+
return bailout->label();
|
177
|
+
}
|
178
|
+
|
179
|
+
// Add a bailout with no live values.
|
180
|
+
Label* AddBailout() { return AddBailout(no_reg, no_reg); }
|
181
|
+
|
182
|
+
private:
|
183
|
+
void Initialize() {
|
184
|
+
mode_ = PRIMARY;
|
185
|
+
has_this_properties_ = false;
|
186
|
+
has_globals_ = false;
|
187
|
+
}
|
188
|
+
|
189
|
+
Handle<JSFunction> closure_;
|
190
|
+
Handle<SharedFunctionInfo> shared_info_;
|
191
|
+
Handle<Script> script_;
|
192
|
+
|
193
|
+
FunctionLiteral* function_;
|
194
|
+
Mode mode_;
|
195
|
+
|
196
|
+
bool is_eval_;
|
197
|
+
int loop_nesting_;
|
198
|
+
|
199
|
+
Handle<Object> receiver_;
|
200
|
+
|
201
|
+
bool has_this_properties_;
|
202
|
+
bool has_globals_;
|
203
|
+
|
204
|
+
// An ordered list of bailout points encountered during fast-path
|
205
|
+
// compilation.
|
206
|
+
List<Bailout*> bailouts_;
|
207
|
+
|
208
|
+
DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
|
209
|
+
};
|
210
|
+
|
211
|
+
|
212
|
+
// The V8 compiler
|
213
|
+
//
|
214
|
+
// General strategy: Source code is translated into an anonymous function w/o
|
215
|
+
// parameters which then can be executed. If the source code contains other
|
216
|
+
// functions, they will be compiled and allocated as part of the compilation
|
217
|
+
// of the source code.
|
218
|
+
|
219
|
+
// Please note this interface returns shared function infos.
|
220
|
+
// This means you need to call Factory::NewFunctionFromSharedFunctionInfo
|
221
|
+
// before you have a real function with a context.
|
222
|
+
|
223
|
+
class Compiler : public AllStatic {
|
224
|
+
public:
|
225
|
+
enum ValidationState { VALIDATE_JSON, DONT_VALIDATE_JSON };
|
226
|
+
|
227
|
+
// All routines return a JSFunction.
|
228
|
+
// If an error occurs an exception is raised and
|
229
|
+
// the return handle contains NULL.
|
230
|
+
|
231
|
+
// Compile a String source within a context.
|
232
|
+
static Handle<SharedFunctionInfo> Compile(Handle<String> source,
|
233
|
+
Handle<Object> script_name,
|
234
|
+
int line_offset,
|
235
|
+
int column_offset,
|
236
|
+
v8::Extension* extension,
|
237
|
+
ScriptDataImpl* pre_data,
|
238
|
+
Handle<Object> script_data,
|
239
|
+
NativesFlag is_natives_code);
|
240
|
+
|
241
|
+
// Compile a String source within a context for Eval.
|
242
|
+
static Handle<SharedFunctionInfo> CompileEval(Handle<String> source,
|
243
|
+
Handle<Context> context,
|
244
|
+
bool is_global,
|
245
|
+
ValidationState validation);
|
246
|
+
|
247
|
+
// Compile from function info (used for lazy compilation). Returns
|
248
|
+
// true on success and false if the compilation resulted in a stack
|
249
|
+
// overflow.
|
250
|
+
static bool CompileLazy(CompilationInfo* info);
|
251
|
+
|
252
|
+
// Compile a shared function info object (the function is possibly
|
253
|
+
// lazily compiled). Called recursively from a backend code
|
254
|
+
// generator 'caller' to build the shared function info.
|
255
|
+
static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node,
|
256
|
+
Handle<Script> script,
|
257
|
+
AstVisitor* caller);
|
258
|
+
|
259
|
+
// Set the function info for a newly compiled function.
|
260
|
+
static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info,
|
261
|
+
FunctionLiteral* lit,
|
262
|
+
bool is_toplevel,
|
263
|
+
Handle<Script> script);
|
264
|
+
|
265
|
+
private:
|
266
|
+
static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
|
267
|
+
Handle<String> name,
|
268
|
+
Handle<String> inferred_name,
|
269
|
+
int start_position,
|
270
|
+
Handle<Script> script,
|
271
|
+
Handle<Code> code);
|
272
|
+
};
|
273
|
+
|
274
|
+
|
275
|
+
#ifdef ENABLE_DEBUGGER_SUPPORT
|
276
|
+
|
277
|
+
Handle<Code> MakeCodeForLiveEdit(CompilationInfo* info);
|
278
|
+
|
279
|
+
#endif
|
280
|
+
|
281
|
+
|
282
|
+
// During compilation we need a global list of handles to constants
|
283
|
+
// for frame elements. When the zone gets deleted, we make sure to
|
284
|
+
// clear this list of handles as well.
|
285
|
+
class CompilationZoneScope : public ZoneScope {
|
286
|
+
public:
|
287
|
+
explicit CompilationZoneScope(ZoneScopeMode mode) : ZoneScope(mode) { }
|
288
|
+
virtual ~CompilationZoneScope() {
|
289
|
+
if (ShouldDeleteOnExit()) {
|
290
|
+
FrameElement::ClearConstantList();
|
291
|
+
Result::ClearConstantList();
|
292
|
+
}
|
293
|
+
}
|
294
|
+
};
|
295
|
+
|
296
|
+
|
297
|
+
} } // namespace v8::internal
|
298
|
+
|
299
|
+
#endif // V8_COMPILER_H_
|
File without changes
|
@@ -50,12 +50,6 @@ enum ContextLookupFlags {
|
|
50
50
|
// must always be allocated via Heap::AllocateContext() or
|
51
51
|
// Factory::NewContext.
|
52
52
|
|
53
|
-
// Comment for special_function_table:
|
54
|
-
// Table for providing optimized/specialized functions.
|
55
|
-
// The array contains triplets [object, general_function, optimized_function].
|
56
|
-
// Primarily added to support built-in optimized variants of
|
57
|
-
// Array.prototype.{push,pop}.
|
58
|
-
|
59
53
|
#define GLOBAL_CONTEXT_FIELDS(V) \
|
60
54
|
V(GLOBAL_PROXY_INDEX, JSObject, global_proxy_object) \
|
61
55
|
V(SECURITY_TOKEN_INDEX, Object, security_token) \
|
@@ -76,26 +70,27 @@ enum ContextLookupFlags {
|
|
76
70
|
V(TO_INTEGER_FUN_INDEX, JSFunction, to_integer_fun) \
|
77
71
|
V(TO_UINT32_FUN_INDEX, JSFunction, to_uint32_fun) \
|
78
72
|
V(TO_INT32_FUN_INDEX, JSFunction, to_int32_fun) \
|
79
|
-
V(TO_BOOLEAN_FUN_INDEX, JSFunction, to_boolean_fun) \
|
80
73
|
V(GLOBAL_EVAL_FUN_INDEX, JSFunction, global_eval_fun) \
|
81
74
|
V(INSTANTIATE_FUN_INDEX, JSFunction, instantiate_fun) \
|
82
75
|
V(CONFIGURE_INSTANCE_FUN_INDEX, JSFunction, configure_instance_fun) \
|
83
76
|
V(FUNCTION_MAP_INDEX, Map, function_map) \
|
77
|
+
V(FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, function_without_prototype_map) \
|
84
78
|
V(FUNCTION_INSTANCE_MAP_INDEX, Map, function_instance_map) \
|
85
79
|
V(JS_ARRAY_MAP_INDEX, Map, js_array_map)\
|
86
|
-
V(
|
80
|
+
V(REGEXP_RESULT_MAP_INDEX, Map, regexp_result_map)\
|
87
81
|
V(ARGUMENTS_BOILERPLATE_INDEX, JSObject, arguments_boilerplate) \
|
88
82
|
V(MESSAGE_LISTENERS_INDEX, JSObject, message_listeners) \
|
89
83
|
V(MAKE_MESSAGE_FUN_INDEX, JSFunction, make_message_fun) \
|
90
84
|
V(GET_STACK_TRACE_LINE_INDEX, JSFunction, get_stack_trace_line_fun) \
|
91
85
|
V(CONFIGURE_GLOBAL_INDEX, JSFunction, configure_global_fun) \
|
92
86
|
V(FUNCTION_CACHE_INDEX, JSObject, function_cache) \
|
87
|
+
V(JSFUNCTION_RESULT_CACHES_INDEX, FixedArray, jsfunction_result_caches) \
|
93
88
|
V(RUNTIME_CONTEXT_INDEX, Context, runtime_context) \
|
94
89
|
V(CALL_AS_FUNCTION_DELEGATE_INDEX, JSFunction, call_as_function_delegate) \
|
95
90
|
V(CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, JSFunction, \
|
96
91
|
call_as_constructor_delegate) \
|
97
|
-
V(EMPTY_SCRIPT_INDEX, Script, empty_script) \
|
98
92
|
V(SCRIPT_FUNCTION_INDEX, JSFunction, script_function) \
|
93
|
+
V(OPAQUE_REFERENCE_FUNCTION_INDEX, JSFunction, opaque_reference_function) \
|
99
94
|
V(CONTEXT_EXTENSION_FUNCTION_INDEX, JSFunction, context_extension_function) \
|
100
95
|
V(OUT_OF_MEMORY_INDEX, Object, out_of_memory) \
|
101
96
|
V(MAP_CACHE_INDEX, Object, map_cache) \
|
@@ -183,7 +178,9 @@ class Context: public FixedArray {
|
|
183
178
|
SECURITY_TOKEN_INDEX,
|
184
179
|
ARGUMENTS_BOILERPLATE_INDEX,
|
185
180
|
JS_ARRAY_MAP_INDEX,
|
181
|
+
REGEXP_RESULT_MAP_INDEX,
|
186
182
|
FUNCTION_MAP_INDEX,
|
183
|
+
FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX,
|
187
184
|
FUNCTION_INSTANCE_MAP_INDEX,
|
188
185
|
INITIAL_OBJECT_PROTOTYPE_INDEX,
|
189
186
|
BOOLEAN_FUNCTION_INDEX,
|
@@ -206,17 +203,17 @@ class Context: public FixedArray {
|
|
206
203
|
GLOBAL_EVAL_FUN_INDEX,
|
207
204
|
INSTANTIATE_FUN_INDEX,
|
208
205
|
CONFIGURE_INSTANCE_FUN_INDEX,
|
209
|
-
SPECIAL_FUNCTION_TABLE_INDEX,
|
210
206
|
MESSAGE_LISTENERS_INDEX,
|
211
207
|
MAKE_MESSAGE_FUN_INDEX,
|
212
208
|
GET_STACK_TRACE_LINE_INDEX,
|
213
209
|
CONFIGURE_GLOBAL_INDEX,
|
214
210
|
FUNCTION_CACHE_INDEX,
|
211
|
+
JSFUNCTION_RESULT_CACHES_INDEX,
|
215
212
|
RUNTIME_CONTEXT_INDEX,
|
216
213
|
CALL_AS_FUNCTION_DELEGATE_INDEX,
|
217
214
|
CALL_AS_CONSTRUCTOR_DELEGATE_INDEX,
|
218
|
-
EMPTY_SCRIPT_INDEX,
|
219
215
|
SCRIPT_FUNCTION_INDEX,
|
216
|
+
OPAQUE_REFERENCE_FUNCTION_INDEX,
|
220
217
|
CONTEXT_EXTENSION_FUNCTION_INDEX,
|
221
218
|
OUT_OF_MEMORY_INDEX,
|
222
219
|
MAP_CACHE_INDEX,
|
@@ -41,21 +41,36 @@
|
|
41
41
|
namespace v8 {
|
42
42
|
namespace internal {
|
43
43
|
|
44
|
-
// The fast double-to-int conversion routine does not guarantee
|
45
|
-
// rounding towards zero
|
46
|
-
|
47
|
-
|
48
|
-
//
|
49
|
-
//
|
50
|
-
|
44
|
+
// The fast double-to-unsigned-int conversion routine does not guarantee
|
45
|
+
// rounding towards zero, or any reasonable value if the argument is larger
|
46
|
+
// than what fits in an unsigned 32-bit integer.
|
47
|
+
static inline unsigned int FastD2UI(double x) {
|
48
|
+
// There is no unsigned version of lrint, so there is no fast path
|
49
|
+
// in this function as there is in FastD2I. Using lrint doesn't work
|
50
|
+
// for values of 2^31 and above.
|
51
|
+
|
52
|
+
// Convert "small enough" doubles to uint32_t by fixing the 32
|
53
|
+
// least significant non-fractional bits in the low 32 bits of the
|
54
|
+
// double, and reading them from there.
|
55
|
+
const double k2Pow52 = 4503599627370496.0;
|
56
|
+
bool negative = x < 0;
|
57
|
+
if (negative) {
|
58
|
+
x = -x;
|
59
|
+
}
|
60
|
+
if (x < k2Pow52) {
|
61
|
+
x += k2Pow52;
|
62
|
+
uint32_t result;
|
63
|
+
#ifdef BIG_ENDIAN_FLOATING_POINT
|
64
|
+
Address mantissa_ptr = reinterpret_cast<Address>(&x) + kIntSize;
|
51
65
|
#else
|
52
|
-
|
53
|
-
// towards zero is implied by the C standard. This means that the
|
54
|
-
// status register of the FPU has to be changed with the 'fldcw'
|
55
|
-
// instruction. This completely stalls the pipeline and takes many
|
56
|
-
// hundreds of clock cycles.
|
57
|
-
return static_cast<int>(x);
|
66
|
+
Address mantissa_ptr = reinterpret_cast<Address>(&x);
|
58
67
|
#endif
|
68
|
+
// Copy least significant 32 bits of mantissa.
|
69
|
+
memcpy(&result, mantissa_ptr, sizeof(result));
|
70
|
+
return negative ? ~result + 1 : result;
|
71
|
+
}
|
72
|
+
// Large number (outside uint32 range), Infinity or NaN.
|
73
|
+
return 0x80000000u; // Return integer indefinite.
|
59
74
|
}
|
60
75
|
|
61
76
|
|
@@ -0,0 +1,1105 @@
|
|
1
|
+
// Copyright 2006-2008 the V8 project authors. All rights reserved.
|
2
|
+
// Redistribution and use in source and binary forms, with or without
|
3
|
+
// modification, are permitted provided that the following conditions are
|
4
|
+
// met:
|
5
|
+
//
|
6
|
+
// * Redistributions of source code must retain the above copyright
|
7
|
+
// notice, this list of conditions and the following disclaimer.
|
8
|
+
// * Redistributions in binary form must reproduce the above
|
9
|
+
// copyright notice, this list of conditions and the following
|
10
|
+
// disclaimer in the documentation and/or other materials provided
|
11
|
+
// with the distribution.
|
12
|
+
// * Neither the name of Google Inc. nor the names of its
|
13
|
+
// contributors may be used to endorse or promote products derived
|
14
|
+
// from this software without specific prior written permission.
|
15
|
+
//
|
16
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
20
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
23
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
#include <stdarg.h>
|
29
|
+
#include <limits.h>
|
30
|
+
|
31
|
+
#include "v8.h"
|
32
|
+
|
33
|
+
#include "conversions-inl.h"
|
34
|
+
#include "factory.h"
|
35
|
+
#include "fast-dtoa.h"
|
36
|
+
#include "scanner.h"
|
37
|
+
|
38
|
+
namespace v8 {
|
39
|
+
namespace internal {
|
40
|
+
|
41
|
+
int HexValue(uc32 c) {
|
42
|
+
if ('0' <= c && c <= '9')
|
43
|
+
return c - '0';
|
44
|
+
if ('a' <= c && c <= 'f')
|
45
|
+
return c - 'a' + 10;
|
46
|
+
if ('A' <= c && c <= 'F')
|
47
|
+
return c - 'A' + 10;
|
48
|
+
return -1;
|
49
|
+
}
|
50
|
+
|
51
|
+
namespace {
|
52
|
+
|
53
|
+
// C++-style iterator adaptor for StringInputBuffer
|
54
|
+
// (unlike C++ iterators the end-marker has different type).
|
55
|
+
class StringInputBufferIterator {
|
56
|
+
public:
|
57
|
+
class EndMarker {};
|
58
|
+
|
59
|
+
explicit StringInputBufferIterator(StringInputBuffer* buffer);
|
60
|
+
|
61
|
+
int operator*() const;
|
62
|
+
void operator++();
|
63
|
+
bool operator==(EndMarker const&) const { return end_; }
|
64
|
+
bool operator!=(EndMarker const& m) const { return !end_; }
|
65
|
+
|
66
|
+
private:
|
67
|
+
StringInputBuffer* const buffer_;
|
68
|
+
int current_;
|
69
|
+
bool end_;
|
70
|
+
};
|
71
|
+
|
72
|
+
|
73
|
+
StringInputBufferIterator::StringInputBufferIterator(
|
74
|
+
StringInputBuffer* buffer) : buffer_(buffer) {
|
75
|
+
++(*this);
|
76
|
+
}
|
77
|
+
|
78
|
+
int StringInputBufferIterator::operator*() const {
|
79
|
+
return current_;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
void StringInputBufferIterator::operator++() {
|
84
|
+
end_ = !buffer_->has_more();
|
85
|
+
if (!end_) {
|
86
|
+
current_ = buffer_->GetNext();
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
template <class Iterator, class EndMark>
|
93
|
+
static bool SubStringEquals(Iterator* current,
|
94
|
+
EndMark end,
|
95
|
+
const char* substring) {
|
96
|
+
ASSERT(**current == *substring);
|
97
|
+
for (substring++; *substring != '\0'; substring++) {
|
98
|
+
++*current;
|
99
|
+
if (*current == end || **current != *substring) return false;
|
100
|
+
}
|
101
|
+
++*current;
|
102
|
+
return true;
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
extern "C" double gay_strtod(const char* s00, const char** se);
|
107
|
+
|
108
|
+
// Maximum number of significant digits in decimal representation.
|
109
|
+
// The longest possible double in decimal representation is
|
110
|
+
// (2^53 - 1) * 2 ^ -1074 that is (2 ^ 53 - 1) * 5 ^ 1074 / 10 ^ 1074
|
111
|
+
// (768 digits). If we parse a number whose first digits are equal to a
|
112
|
+
// mean of 2 adjacent doubles (that could have up to 769 digits) the result
|
113
|
+
// must be rounded to the bigger one unless the tail consists of zeros, so
|
114
|
+
// we don't need to preserve all the digits.
|
115
|
+
const int kMaxSignificantDigits = 772;
|
116
|
+
|
117
|
+
|
118
|
+
static const double JUNK_STRING_VALUE = OS::nan_value();
|
119
|
+
|
120
|
+
|
121
|
+
// Returns true if a nonspace found and false if the end has reached.
|
122
|
+
template <class Iterator, class EndMark>
|
123
|
+
static inline bool AdvanceToNonspace(Iterator* current, EndMark end) {
|
124
|
+
while (*current != end) {
|
125
|
+
if (!Scanner::kIsWhiteSpace.get(**current)) return true;
|
126
|
+
++*current;
|
127
|
+
}
|
128
|
+
return false;
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
static bool isDigit(int x, int radix) {
|
133
|
+
return (x >= '0' && x <= '9' && x < '0' + radix)
|
134
|
+
|| (radix > 10 && x >= 'a' && x < 'a' + radix - 10)
|
135
|
+
|| (radix > 10 && x >= 'A' && x < 'A' + radix - 10);
|
136
|
+
}
|
137
|
+
|
138
|
+
|
139
|
+
static double SignedZero(bool sign) {
|
140
|
+
return sign ? -0.0 : 0.0;
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
// Parsing integers with radix 2, 4, 8, 16, 32. Assumes current != end.
|
145
|
+
template <int radix_log_2, class Iterator, class EndMark>
|
146
|
+
static double InternalStringToIntDouble(Iterator current,
|
147
|
+
EndMark end,
|
148
|
+
bool sign,
|
149
|
+
bool allow_trailing_junk) {
|
150
|
+
ASSERT(current != end);
|
151
|
+
|
152
|
+
// Skip leading 0s.
|
153
|
+
while (*current == '0') {
|
154
|
+
++current;
|
155
|
+
if (current == end) return SignedZero(sign);
|
156
|
+
}
|
157
|
+
|
158
|
+
int64_t number = 0;
|
159
|
+
int exponent = 0;
|
160
|
+
const int radix = (1 << radix_log_2);
|
161
|
+
|
162
|
+
do {
|
163
|
+
int digit;
|
164
|
+
if (*current >= '0' && *current <= '9' && *current < '0' + radix) {
|
165
|
+
digit = static_cast<char>(*current) - '0';
|
166
|
+
} else if (radix > 10 && *current >= 'a' && *current < 'a' + radix - 10) {
|
167
|
+
digit = static_cast<char>(*current) - 'a' + 10;
|
168
|
+
} else if (radix > 10 && *current >= 'A' && *current < 'A' + radix - 10) {
|
169
|
+
digit = static_cast<char>(*current) - 'A' + 10;
|
170
|
+
} else {
|
171
|
+
if (allow_trailing_junk || !AdvanceToNonspace(¤t, end)) {
|
172
|
+
break;
|
173
|
+
} else {
|
174
|
+
return JUNK_STRING_VALUE;
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
number = number * radix + digit;
|
179
|
+
int overflow = static_cast<int>(number >> 53);
|
180
|
+
if (overflow != 0) {
|
181
|
+
// Overflow occurred. Need to determine which direction to round the
|
182
|
+
// result.
|
183
|
+
int overflow_bits_count = 1;
|
184
|
+
while (overflow > 1) {
|
185
|
+
overflow_bits_count++;
|
186
|
+
overflow >>= 1;
|
187
|
+
}
|
188
|
+
|
189
|
+
int dropped_bits_mask = ((1 << overflow_bits_count) - 1);
|
190
|
+
int dropped_bits = static_cast<int>(number) & dropped_bits_mask;
|
191
|
+
number >>= overflow_bits_count;
|
192
|
+
exponent = overflow_bits_count;
|
193
|
+
|
194
|
+
bool zero_tail = true;
|
195
|
+
while (true) {
|
196
|
+
++current;
|
197
|
+
if (current == end || !isDigit(*current, radix)) break;
|
198
|
+
zero_tail = zero_tail && *current == '0';
|
199
|
+
exponent += radix_log_2;
|
200
|
+
}
|
201
|
+
|
202
|
+
if (!allow_trailing_junk && AdvanceToNonspace(¤t, end)) {
|
203
|
+
return JUNK_STRING_VALUE;
|
204
|
+
}
|
205
|
+
|
206
|
+
int middle_value = (1 << (overflow_bits_count - 1));
|
207
|
+
if (dropped_bits > middle_value) {
|
208
|
+
number++; // Rounding up.
|
209
|
+
} else if (dropped_bits == middle_value) {
|
210
|
+
// Rounding to even to consistency with decimals: half-way case rounds
|
211
|
+
// up if significant part is odd and down otherwise.
|
212
|
+
if ((number & 1) != 0 || !zero_tail) {
|
213
|
+
number++; // Rounding up.
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
// Rounding up may cause overflow.
|
218
|
+
if ((number & ((int64_t)1 << 53)) != 0) {
|
219
|
+
exponent++;
|
220
|
+
number >>= 1;
|
221
|
+
}
|
222
|
+
break;
|
223
|
+
}
|
224
|
+
++current;
|
225
|
+
} while (current != end);
|
226
|
+
|
227
|
+
ASSERT(number < ((int64_t)1 << 53));
|
228
|
+
ASSERT(static_cast<int64_t>(static_cast<double>(number)) == number);
|
229
|
+
|
230
|
+
if (exponent == 0) {
|
231
|
+
if (sign) {
|
232
|
+
if (number == 0) return -0.0;
|
233
|
+
number = -number;
|
234
|
+
}
|
235
|
+
return static_cast<double>(number);
|
236
|
+
}
|
237
|
+
|
238
|
+
ASSERT(number != 0);
|
239
|
+
// The double could be constructed faster from number (mantissa), exponent
|
240
|
+
// and sign. Assuming it's a rare case more simple code is used.
|
241
|
+
return static_cast<double>(sign ? -number : number) * pow(2.0, exponent);
|
242
|
+
}
|
243
|
+
|
244
|
+
|
245
|
+
template <class Iterator, class EndMark>
|
246
|
+
static double InternalStringToInt(Iterator current, EndMark end, int radix) {
|
247
|
+
const bool allow_trailing_junk = true;
|
248
|
+
const double empty_string_val = JUNK_STRING_VALUE;
|
249
|
+
|
250
|
+
if (!AdvanceToNonspace(¤t, end)) return empty_string_val;
|
251
|
+
|
252
|
+
bool sign = false;
|
253
|
+
bool leading_zero = false;
|
254
|
+
|
255
|
+
if (*current == '+') {
|
256
|
+
// Ignore leading sign; skip following spaces.
|
257
|
+
++current;
|
258
|
+
if (!AdvanceToNonspace(¤t, end)) return JUNK_STRING_VALUE;
|
259
|
+
} else if (*current == '-') {
|
260
|
+
++current;
|
261
|
+
if (!AdvanceToNonspace(¤t, end)) return JUNK_STRING_VALUE;
|
262
|
+
sign = true;
|
263
|
+
}
|
264
|
+
|
265
|
+
if (radix == 0) {
|
266
|
+
// Radix detection.
|
267
|
+
if (*current == '0') {
|
268
|
+
++current;
|
269
|
+
if (current == end) return SignedZero(sign);
|
270
|
+
if (*current == 'x' || *current == 'X') {
|
271
|
+
radix = 16;
|
272
|
+
++current;
|
273
|
+
if (current == end) return JUNK_STRING_VALUE;
|
274
|
+
} else {
|
275
|
+
radix = 8;
|
276
|
+
leading_zero = true;
|
277
|
+
}
|
278
|
+
} else {
|
279
|
+
radix = 10;
|
280
|
+
}
|
281
|
+
} else if (radix == 16) {
|
282
|
+
if (*current == '0') {
|
283
|
+
// Allow "0x" prefix.
|
284
|
+
++current;
|
285
|
+
if (current == end) return SignedZero(sign);
|
286
|
+
if (*current == 'x' || *current == 'X') {
|
287
|
+
++current;
|
288
|
+
if (current == end) return JUNK_STRING_VALUE;
|
289
|
+
} else {
|
290
|
+
leading_zero = true;
|
291
|
+
}
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
if (radix < 2 || radix > 36) return JUNK_STRING_VALUE;
|
296
|
+
|
297
|
+
// Skip leading zeros.
|
298
|
+
while (*current == '0') {
|
299
|
+
leading_zero = true;
|
300
|
+
++current;
|
301
|
+
if (current == end) return SignedZero(sign);
|
302
|
+
}
|
303
|
+
|
304
|
+
if (!leading_zero && !isDigit(*current, radix)) {
|
305
|
+
return JUNK_STRING_VALUE;
|
306
|
+
}
|
307
|
+
|
308
|
+
if (IsPowerOf2(radix)) {
|
309
|
+
switch (radix) {
|
310
|
+
case 2:
|
311
|
+
return InternalStringToIntDouble<1>(
|
312
|
+
current, end, sign, allow_trailing_junk);
|
313
|
+
case 4:
|
314
|
+
return InternalStringToIntDouble<2>(
|
315
|
+
current, end, sign, allow_trailing_junk);
|
316
|
+
case 8:
|
317
|
+
return InternalStringToIntDouble<3>(
|
318
|
+
current, end, sign, allow_trailing_junk);
|
319
|
+
|
320
|
+
case 16:
|
321
|
+
return InternalStringToIntDouble<4>(
|
322
|
+
current, end, sign, allow_trailing_junk);
|
323
|
+
|
324
|
+
case 32:
|
325
|
+
return InternalStringToIntDouble<5>(
|
326
|
+
current, end, sign, allow_trailing_junk);
|
327
|
+
default:
|
328
|
+
UNREACHABLE();
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
if (radix == 10) {
|
333
|
+
// Parsing with strtod.
|
334
|
+
const int kMaxSignificantDigits = 309; // Doubles are less than 1.8e308.
|
335
|
+
// The buffer may contain up to kMaxSignificantDigits + 1 digits and a zero
|
336
|
+
// end.
|
337
|
+
const int kBufferSize = kMaxSignificantDigits + 2;
|
338
|
+
char buffer[kBufferSize];
|
339
|
+
int buffer_pos = 0;
|
340
|
+
while (*current >= '0' && *current <= '9') {
|
341
|
+
if (buffer_pos <= kMaxSignificantDigits) {
|
342
|
+
// If the number has more than kMaxSignificantDigits it will be parsed
|
343
|
+
// as infinity.
|
344
|
+
ASSERT(buffer_pos < kBufferSize);
|
345
|
+
buffer[buffer_pos++] = static_cast<char>(*current);
|
346
|
+
}
|
347
|
+
++current;
|
348
|
+
if (current == end) break;
|
349
|
+
}
|
350
|
+
|
351
|
+
if (!allow_trailing_junk && AdvanceToNonspace(¤t, end)) {
|
352
|
+
return JUNK_STRING_VALUE;
|
353
|
+
}
|
354
|
+
|
355
|
+
ASSERT(buffer_pos < kBufferSize);
|
356
|
+
buffer[buffer_pos++] = '\0';
|
357
|
+
return sign ? -gay_strtod(buffer, NULL) : gay_strtod(buffer, NULL);
|
358
|
+
}
|
359
|
+
|
360
|
+
// The following code causes accumulating rounding error for numbers greater
|
361
|
+
// than ~2^56. It's explicitly allowed in the spec: "if R is not 2, 4, 8, 10,
|
362
|
+
// 16, or 32, then mathInt may be an implementation-dependent approximation to
|
363
|
+
// the mathematical integer value" (15.1.2.2).
|
364
|
+
|
365
|
+
int lim_0 = '0' + (radix < 10 ? radix : 10);
|
366
|
+
int lim_a = 'a' + (radix - 10);
|
367
|
+
int lim_A = 'A' + (radix - 10);
|
368
|
+
|
369
|
+
// NOTE: The code for computing the value may seem a bit complex at
|
370
|
+
// first glance. It is structured to use 32-bit multiply-and-add
|
371
|
+
// loops as long as possible to avoid loosing precision.
|
372
|
+
|
373
|
+
double v = 0.0;
|
374
|
+
bool done = false;
|
375
|
+
do {
|
376
|
+
// Parse the longest part of the string starting at index j
|
377
|
+
// possible while keeping the multiplier, and thus the part
|
378
|
+
// itself, within 32 bits.
|
379
|
+
unsigned int part = 0, multiplier = 1;
|
380
|
+
while (true) {
|
381
|
+
int d;
|
382
|
+
if (*current >= '0' && *current < lim_0) {
|
383
|
+
d = *current - '0';
|
384
|
+
} else if (*current >= 'a' && *current < lim_a) {
|
385
|
+
d = *current - 'a' + 10;
|
386
|
+
} else if (*current >= 'A' && *current < lim_A) {
|
387
|
+
d = *current - 'A' + 10;
|
388
|
+
} else {
|
389
|
+
done = true;
|
390
|
+
break;
|
391
|
+
}
|
392
|
+
|
393
|
+
// Update the value of the part as long as the multiplier fits
|
394
|
+
// in 32 bits. When we can't guarantee that the next iteration
|
395
|
+
// will not overflow the multiplier, we stop parsing the part
|
396
|
+
// by leaving the loop.
|
397
|
+
const unsigned int kMaximumMultiplier = 0xffffffffU / 36;
|
398
|
+
uint32_t m = multiplier * radix;
|
399
|
+
if (m > kMaximumMultiplier) break;
|
400
|
+
part = part * radix + d;
|
401
|
+
multiplier = m;
|
402
|
+
ASSERT(multiplier > part);
|
403
|
+
|
404
|
+
++current;
|
405
|
+
if (current == end) {
|
406
|
+
done = true;
|
407
|
+
break;
|
408
|
+
}
|
409
|
+
}
|
410
|
+
|
411
|
+
// Update the value and skip the part in the string.
|
412
|
+
v = v * multiplier + part;
|
413
|
+
} while (!done);
|
414
|
+
|
415
|
+
if (!allow_trailing_junk && AdvanceToNonspace(¤t, end)) {
|
416
|
+
return JUNK_STRING_VALUE;
|
417
|
+
}
|
418
|
+
|
419
|
+
return sign ? -v : v;
|
420
|
+
}
|
421
|
+
|
422
|
+
|
423
|
+
// Converts a string to a double value. Assumes the Iterator supports
|
424
|
+
// the following operations:
|
425
|
+
// 1. current == end (other ops are not allowed), current != end.
|
426
|
+
// 2. *current - gets the current character in the sequence.
|
427
|
+
// 3. ++current (advances the position).
|
428
|
+
template <class Iterator, class EndMark>
|
429
|
+
static double InternalStringToDouble(Iterator current,
|
430
|
+
EndMark end,
|
431
|
+
int flags,
|
432
|
+
double empty_string_val) {
|
433
|
+
// To make sure that iterator dereferencing is valid the following
|
434
|
+
// convention is used:
|
435
|
+
// 1. Each '++current' statement is followed by check for equality to 'end'.
|
436
|
+
// 2. If AdvanceToNonspace returned false then current == end.
|
437
|
+
// 3. If 'current' becomes be equal to 'end' the function returns or goes to
|
438
|
+
// 'parsing_done'.
|
439
|
+
// 4. 'current' is not dereferenced after the 'parsing_done' label.
|
440
|
+
// 5. Code before 'parsing_done' may rely on 'current != end'.
|
441
|
+
if (!AdvanceToNonspace(¤t, end)) return empty_string_val;
|
442
|
+
|
443
|
+
const bool allow_trailing_junk = (flags & ALLOW_TRAILING_JUNK) != 0;
|
444
|
+
|
445
|
+
// The longest form of simplified number is: "-<significant digits>'.1eXXX\0".
|
446
|
+
const int kBufferSize = kMaxSignificantDigits + 10;
|
447
|
+
char buffer[kBufferSize]; // NOLINT: size is known at compile time.
|
448
|
+
int buffer_pos = 0;
|
449
|
+
|
450
|
+
// Exponent will be adjusted if insignificant digits of the integer part
|
451
|
+
// or insignificant leading zeros of the fractional part are dropped.
|
452
|
+
int exponent = 0;
|
453
|
+
int significant_digits = 0;
|
454
|
+
int insignificant_digits = 0;
|
455
|
+
bool nonzero_digit_dropped = false;
|
456
|
+
bool fractional_part = false;
|
457
|
+
|
458
|
+
bool sign = false;
|
459
|
+
|
460
|
+
if (*current == '+') {
|
461
|
+
// Ignore leading sign; skip following spaces.
|
462
|
+
++current;
|
463
|
+
if (!AdvanceToNonspace(¤t, end)) return JUNK_STRING_VALUE;
|
464
|
+
} else if (*current == '-') {
|
465
|
+
buffer[buffer_pos++] = '-';
|
466
|
+
++current;
|
467
|
+
if (!AdvanceToNonspace(¤t, end)) return JUNK_STRING_VALUE;
|
468
|
+
sign = true;
|
469
|
+
}
|
470
|
+
|
471
|
+
static const char kInfinitySymbol[] = "Infinity";
|
472
|
+
if (*current == kInfinitySymbol[0]) {
|
473
|
+
if (!SubStringEquals(¤t, end, kInfinitySymbol)) {
|
474
|
+
return JUNK_STRING_VALUE;
|
475
|
+
}
|
476
|
+
|
477
|
+
if (!allow_trailing_junk && AdvanceToNonspace(¤t, end)) {
|
478
|
+
return JUNK_STRING_VALUE;
|
479
|
+
}
|
480
|
+
|
481
|
+
ASSERT(buffer_pos == 0 || buffer[0] == '-');
|
482
|
+
return buffer_pos > 0 ? -V8_INFINITY : V8_INFINITY;
|
483
|
+
}
|
484
|
+
|
485
|
+
bool leading_zero = false;
|
486
|
+
if (*current == '0') {
|
487
|
+
++current;
|
488
|
+
if (current == end) return SignedZero(sign);
|
489
|
+
|
490
|
+
leading_zero = true;
|
491
|
+
|
492
|
+
// It could be hexadecimal value.
|
493
|
+
if ((flags & ALLOW_HEX) && (*current == 'x' || *current == 'X')) {
|
494
|
+
++current;
|
495
|
+
if (current == end || !isDigit(*current, 16)) {
|
496
|
+
return JUNK_STRING_VALUE; // "0x".
|
497
|
+
}
|
498
|
+
|
499
|
+
bool sign = (buffer_pos > 0 && buffer[0] == '-');
|
500
|
+
return InternalStringToIntDouble<4>(current,
|
501
|
+
end,
|
502
|
+
sign,
|
503
|
+
allow_trailing_junk);
|
504
|
+
}
|
505
|
+
|
506
|
+
// Ignore leading zeros in the integer part.
|
507
|
+
while (*current == '0') {
|
508
|
+
++current;
|
509
|
+
if (current == end) return SignedZero(sign);
|
510
|
+
}
|
511
|
+
}
|
512
|
+
|
513
|
+
bool octal = leading_zero && (flags & ALLOW_OCTALS) != 0;
|
514
|
+
|
515
|
+
// Copy significant digits of the integer part (if any) to the buffer.
|
516
|
+
while (*current >= '0' && *current <= '9') {
|
517
|
+
if (significant_digits < kMaxSignificantDigits) {
|
518
|
+
ASSERT(buffer_pos < kBufferSize);
|
519
|
+
buffer[buffer_pos++] = static_cast<char>(*current);
|
520
|
+
significant_digits++;
|
521
|
+
// Will later check if it's an octal in the buffer.
|
522
|
+
} else {
|
523
|
+
insignificant_digits++; // Move the digit into the exponential part.
|
524
|
+
nonzero_digit_dropped = nonzero_digit_dropped || *current != '0';
|
525
|
+
}
|
526
|
+
octal = octal && *current < '8';
|
527
|
+
++current;
|
528
|
+
if (current == end) goto parsing_done;
|
529
|
+
}
|
530
|
+
|
531
|
+
if (significant_digits == 0) {
|
532
|
+
octal = false;
|
533
|
+
}
|
534
|
+
|
535
|
+
if (*current == '.') {
|
536
|
+
++current;
|
537
|
+
if (current == end) {
|
538
|
+
if (significant_digits == 0 && !leading_zero) {
|
539
|
+
return JUNK_STRING_VALUE;
|
540
|
+
} else {
|
541
|
+
goto parsing_done;
|
542
|
+
}
|
543
|
+
}
|
544
|
+
|
545
|
+
if (significant_digits == 0) {
|
546
|
+
// octal = false;
|
547
|
+
// Integer part consists of 0 or is absent. Significant digits start after
|
548
|
+
// leading zeros (if any).
|
549
|
+
while (*current == '0') {
|
550
|
+
++current;
|
551
|
+
if (current == end) return SignedZero(sign);
|
552
|
+
exponent--; // Move this 0 into the exponent.
|
553
|
+
}
|
554
|
+
}
|
555
|
+
|
556
|
+
ASSERT(buffer_pos < kBufferSize);
|
557
|
+
buffer[buffer_pos++] = '.';
|
558
|
+
fractional_part = true;
|
559
|
+
|
560
|
+
// There is the fractional part.
|
561
|
+
while (*current >= '0' && *current <= '9') {
|
562
|
+
if (significant_digits < kMaxSignificantDigits) {
|
563
|
+
ASSERT(buffer_pos < kBufferSize);
|
564
|
+
buffer[buffer_pos++] = static_cast<char>(*current);
|
565
|
+
significant_digits++;
|
566
|
+
} else {
|
567
|
+
// Ignore insignificant digits in the fractional part.
|
568
|
+
nonzero_digit_dropped = nonzero_digit_dropped || *current != '0';
|
569
|
+
}
|
570
|
+
++current;
|
571
|
+
if (current == end) goto parsing_done;
|
572
|
+
}
|
573
|
+
}
|
574
|
+
|
575
|
+
if (!leading_zero && exponent == 0 && significant_digits == 0) {
|
576
|
+
// If leading_zeros is true then the string contains zeros.
|
577
|
+
// If exponent < 0 then string was [+-]\.0*...
|
578
|
+
// If significant_digits != 0 the string is not equal to 0.
|
579
|
+
// Otherwise there are no digits in the string.
|
580
|
+
return JUNK_STRING_VALUE;
|
581
|
+
}
|
582
|
+
|
583
|
+
// Parse exponential part.
|
584
|
+
if (*current == 'e' || *current == 'E') {
|
585
|
+
if (octal) return JUNK_STRING_VALUE;
|
586
|
+
++current;
|
587
|
+
if (current == end) {
|
588
|
+
if (allow_trailing_junk) {
|
589
|
+
goto parsing_done;
|
590
|
+
} else {
|
591
|
+
return JUNK_STRING_VALUE;
|
592
|
+
}
|
593
|
+
}
|
594
|
+
char sign = '+';
|
595
|
+
if (*current == '+' || *current == '-') {
|
596
|
+
sign = static_cast<char>(*current);
|
597
|
+
++current;
|
598
|
+
if (current == end) {
|
599
|
+
if (allow_trailing_junk) {
|
600
|
+
goto parsing_done;
|
601
|
+
} else {
|
602
|
+
return JUNK_STRING_VALUE;
|
603
|
+
}
|
604
|
+
}
|
605
|
+
}
|
606
|
+
|
607
|
+
if (current == end || *current < '0' || *current > '9') {
|
608
|
+
if (allow_trailing_junk) {
|
609
|
+
goto parsing_done;
|
610
|
+
} else {
|
611
|
+
return JUNK_STRING_VALUE;
|
612
|
+
}
|
613
|
+
}
|
614
|
+
|
615
|
+
const int max_exponent = INT_MAX / 2;
|
616
|
+
ASSERT(-max_exponent / 2 <= exponent && exponent <= max_exponent / 2);
|
617
|
+
int num = 0;
|
618
|
+
do {
|
619
|
+
// Check overflow.
|
620
|
+
int digit = *current - '0';
|
621
|
+
if (num >= max_exponent / 10
|
622
|
+
&& !(num == max_exponent / 10 && digit <= max_exponent % 10)) {
|
623
|
+
num = max_exponent;
|
624
|
+
} else {
|
625
|
+
num = num * 10 + digit;
|
626
|
+
}
|
627
|
+
++current;
|
628
|
+
} while (current != end && *current >= '0' && *current <= '9');
|
629
|
+
|
630
|
+
exponent += (sign == '-' ? -num : num);
|
631
|
+
}
|
632
|
+
|
633
|
+
if (!allow_trailing_junk && AdvanceToNonspace(¤t, end)) {
|
634
|
+
return JUNK_STRING_VALUE;
|
635
|
+
}
|
636
|
+
|
637
|
+
parsing_done:
|
638
|
+
exponent += insignificant_digits;
|
639
|
+
|
640
|
+
if (octal) {
|
641
|
+
bool sign = buffer[0] == '-';
|
642
|
+
int start_pos = (sign ? 1 : 0);
|
643
|
+
|
644
|
+
return InternalStringToIntDouble<3>(buffer + start_pos,
|
645
|
+
buffer + buffer_pos,
|
646
|
+
sign,
|
647
|
+
allow_trailing_junk);
|
648
|
+
}
|
649
|
+
|
650
|
+
if (nonzero_digit_dropped) {
|
651
|
+
if (insignificant_digits) buffer[buffer_pos++] = '.';
|
652
|
+
buffer[buffer_pos++] = '1';
|
653
|
+
}
|
654
|
+
|
655
|
+
// If the number has no more than kMaxDigitsInInt digits and doesn't have
|
656
|
+
// fractional part it could be parsed faster (without checks for
|
657
|
+
// spaces, overflow, etc.).
|
658
|
+
const int kMaxDigitsInInt = 9 * sizeof(int) / 4; // NOLINT
|
659
|
+
|
660
|
+
if (exponent != 0) {
|
661
|
+
ASSERT(buffer_pos < kBufferSize);
|
662
|
+
buffer[buffer_pos++] = 'e';
|
663
|
+
if (exponent < 0) {
|
664
|
+
ASSERT(buffer_pos < kBufferSize);
|
665
|
+
buffer[buffer_pos++] = '-';
|
666
|
+
exponent = -exponent;
|
667
|
+
}
|
668
|
+
if (exponent > 999) exponent = 999; // Result will be Infinity or 0 or -0.
|
669
|
+
|
670
|
+
const int exp_digits = 3;
|
671
|
+
for (int i = 0; i < exp_digits; i++) {
|
672
|
+
buffer[buffer_pos + exp_digits - 1 - i] = '0' + exponent % 10;
|
673
|
+
exponent /= 10;
|
674
|
+
}
|
675
|
+
ASSERT(exponent == 0);
|
676
|
+
buffer_pos += exp_digits;
|
677
|
+
} else if (!fractional_part && significant_digits <= kMaxDigitsInInt) {
|
678
|
+
if (significant_digits == 0) return SignedZero(sign);
|
679
|
+
ASSERT(buffer_pos > 0);
|
680
|
+
int num = 0;
|
681
|
+
int start_pos = (buffer[0] == '-' ? 1 : 0);
|
682
|
+
for (int i = start_pos; i < buffer_pos; i++) {
|
683
|
+
ASSERT(buffer[i] >= '0' && buffer[i] <= '9');
|
684
|
+
num = 10 * num + (buffer[i] - '0');
|
685
|
+
}
|
686
|
+
return static_cast<double>(start_pos == 0 ? num : -num);
|
687
|
+
}
|
688
|
+
|
689
|
+
ASSERT(buffer_pos < kBufferSize);
|
690
|
+
buffer[buffer_pos] = '\0';
|
691
|
+
|
692
|
+
return gay_strtod(buffer, NULL);
|
693
|
+
}
|
694
|
+
|
695
|
+
double StringToDouble(String* str, int flags, double empty_string_val) {
|
696
|
+
StringShape shape(str);
|
697
|
+
if (shape.IsSequentialAscii()) {
|
698
|
+
const char* begin = SeqAsciiString::cast(str)->GetChars();
|
699
|
+
const char* end = begin + str->length();
|
700
|
+
return InternalStringToDouble(begin, end, flags, empty_string_val);
|
701
|
+
} else if (shape.IsSequentialTwoByte()) {
|
702
|
+
const uc16* begin = SeqTwoByteString::cast(str)->GetChars();
|
703
|
+
const uc16* end = begin + str->length();
|
704
|
+
return InternalStringToDouble(begin, end, flags, empty_string_val);
|
705
|
+
} else {
|
706
|
+
StringInputBuffer buffer(str);
|
707
|
+
return InternalStringToDouble(StringInputBufferIterator(&buffer),
|
708
|
+
StringInputBufferIterator::EndMarker(),
|
709
|
+
flags,
|
710
|
+
empty_string_val);
|
711
|
+
}
|
712
|
+
}
|
713
|
+
|
714
|
+
|
715
|
+
double StringToInt(String* str, int radix) {
|
716
|
+
StringShape shape(str);
|
717
|
+
if (shape.IsSequentialAscii()) {
|
718
|
+
const char* begin = SeqAsciiString::cast(str)->GetChars();
|
719
|
+
const char* end = begin + str->length();
|
720
|
+
return InternalStringToInt(begin, end, radix);
|
721
|
+
} else if (shape.IsSequentialTwoByte()) {
|
722
|
+
const uc16* begin = SeqTwoByteString::cast(str)->GetChars();
|
723
|
+
const uc16* end = begin + str->length();
|
724
|
+
return InternalStringToInt(begin, end, radix);
|
725
|
+
} else {
|
726
|
+
StringInputBuffer buffer(str);
|
727
|
+
return InternalStringToInt(StringInputBufferIterator(&buffer),
|
728
|
+
StringInputBufferIterator::EndMarker(),
|
729
|
+
radix);
|
730
|
+
}
|
731
|
+
}
|
732
|
+
|
733
|
+
|
734
|
+
double StringToDouble(const char* str, int flags, double empty_string_val) {
|
735
|
+
const char* end = str + StrLength(str);
|
736
|
+
|
737
|
+
return InternalStringToDouble(str, end, flags, empty_string_val);
|
738
|
+
}
|
739
|
+
|
740
|
+
|
741
|
+
extern "C" char* dtoa(double d, int mode, int ndigits,
|
742
|
+
int* decpt, int* sign, char** rve);
|
743
|
+
|
744
|
+
extern "C" void freedtoa(char* s);
|
745
|
+
|
746
|
+
const char* DoubleToCString(double v, Vector<char> buffer) {
|
747
|
+
StringBuilder builder(buffer.start(), buffer.length());
|
748
|
+
|
749
|
+
switch (fpclassify(v)) {
|
750
|
+
case FP_NAN:
|
751
|
+
builder.AddString("NaN");
|
752
|
+
break;
|
753
|
+
|
754
|
+
case FP_INFINITE:
|
755
|
+
if (v < 0.0) {
|
756
|
+
builder.AddString("-Infinity");
|
757
|
+
} else {
|
758
|
+
builder.AddString("Infinity");
|
759
|
+
}
|
760
|
+
break;
|
761
|
+
|
762
|
+
case FP_ZERO:
|
763
|
+
builder.AddCharacter('0');
|
764
|
+
break;
|
765
|
+
|
766
|
+
default: {
|
767
|
+
int decimal_point;
|
768
|
+
int sign;
|
769
|
+
|
770
|
+
char* decimal_rep;
|
771
|
+
bool used_gay_dtoa = false;
|
772
|
+
const int kFastDtoaBufferCapacity = kFastDtoaMaximalLength + 1;
|
773
|
+
char fast_dtoa_buffer[kFastDtoaBufferCapacity];
|
774
|
+
int length;
|
775
|
+
if (FastDtoa(v, Vector<char>(fast_dtoa_buffer, kFastDtoaBufferCapacity),
|
776
|
+
&sign, &length, &decimal_point)) {
|
777
|
+
decimal_rep = fast_dtoa_buffer;
|
778
|
+
} else {
|
779
|
+
decimal_rep = dtoa(v, 0, 0, &decimal_point, &sign, NULL);
|
780
|
+
used_gay_dtoa = true;
|
781
|
+
length = StrLength(decimal_rep);
|
782
|
+
}
|
783
|
+
|
784
|
+
if (sign) builder.AddCharacter('-');
|
785
|
+
|
786
|
+
if (length <= decimal_point && decimal_point <= 21) {
|
787
|
+
// ECMA-262 section 9.8.1 step 6.
|
788
|
+
builder.AddString(decimal_rep);
|
789
|
+
builder.AddPadding('0', decimal_point - length);
|
790
|
+
|
791
|
+
} else if (0 < decimal_point && decimal_point <= 21) {
|
792
|
+
// ECMA-262 section 9.8.1 step 7.
|
793
|
+
builder.AddSubstring(decimal_rep, decimal_point);
|
794
|
+
builder.AddCharacter('.');
|
795
|
+
builder.AddString(decimal_rep + decimal_point);
|
796
|
+
|
797
|
+
} else if (decimal_point <= 0 && decimal_point > -6) {
|
798
|
+
// ECMA-262 section 9.8.1 step 8.
|
799
|
+
builder.AddString("0.");
|
800
|
+
builder.AddPadding('0', -decimal_point);
|
801
|
+
builder.AddString(decimal_rep);
|
802
|
+
|
803
|
+
} else {
|
804
|
+
// ECMA-262 section 9.8.1 step 9 and 10 combined.
|
805
|
+
builder.AddCharacter(decimal_rep[0]);
|
806
|
+
if (length != 1) {
|
807
|
+
builder.AddCharacter('.');
|
808
|
+
builder.AddString(decimal_rep + 1);
|
809
|
+
}
|
810
|
+
builder.AddCharacter('e');
|
811
|
+
builder.AddCharacter((decimal_point >= 0) ? '+' : '-');
|
812
|
+
int exponent = decimal_point - 1;
|
813
|
+
if (exponent < 0) exponent = -exponent;
|
814
|
+
builder.AddFormatted("%d", exponent);
|
815
|
+
}
|
816
|
+
|
817
|
+
if (used_gay_dtoa) freedtoa(decimal_rep);
|
818
|
+
}
|
819
|
+
}
|
820
|
+
return builder.Finalize();
|
821
|
+
}
|
822
|
+
|
823
|
+
|
824
|
+
const char* IntToCString(int n, Vector<char> buffer) {
|
825
|
+
bool negative = false;
|
826
|
+
if (n < 0) {
|
827
|
+
// We must not negate the most negative int.
|
828
|
+
if (n == kMinInt) return DoubleToCString(n, buffer);
|
829
|
+
negative = true;
|
830
|
+
n = -n;
|
831
|
+
}
|
832
|
+
// Build the string backwards from the least significant digit.
|
833
|
+
int i = buffer.length();
|
834
|
+
buffer[--i] = '\0';
|
835
|
+
do {
|
836
|
+
buffer[--i] = '0' + (n % 10);
|
837
|
+
n /= 10;
|
838
|
+
} while (n);
|
839
|
+
if (negative) buffer[--i] = '-';
|
840
|
+
return buffer.start() + i;
|
841
|
+
}
|
842
|
+
|
843
|
+
|
844
|
+
char* DoubleToFixedCString(double value, int f) {
|
845
|
+
ASSERT(f >= 0);
|
846
|
+
|
847
|
+
bool negative = false;
|
848
|
+
double abs_value = value;
|
849
|
+
if (value < 0) {
|
850
|
+
abs_value = -value;
|
851
|
+
negative = true;
|
852
|
+
}
|
853
|
+
|
854
|
+
if (abs_value >= 1e21) {
|
855
|
+
char arr[100];
|
856
|
+
Vector<char> buffer(arr, ARRAY_SIZE(arr));
|
857
|
+
return StrDup(DoubleToCString(value, buffer));
|
858
|
+
}
|
859
|
+
|
860
|
+
// Find a sufficiently precise decimal representation of n.
|
861
|
+
int decimal_point;
|
862
|
+
int sign;
|
863
|
+
char* decimal_rep = dtoa(abs_value, 3, f, &decimal_point, &sign, NULL);
|
864
|
+
int decimal_rep_length = StrLength(decimal_rep);
|
865
|
+
|
866
|
+
// Create a representation that is padded with zeros if needed.
|
867
|
+
int zero_prefix_length = 0;
|
868
|
+
int zero_postfix_length = 0;
|
869
|
+
|
870
|
+
if (decimal_point <= 0) {
|
871
|
+
zero_prefix_length = -decimal_point + 1;
|
872
|
+
decimal_point = 1;
|
873
|
+
}
|
874
|
+
|
875
|
+
if (zero_prefix_length + decimal_rep_length < decimal_point + f) {
|
876
|
+
zero_postfix_length = decimal_point + f - decimal_rep_length -
|
877
|
+
zero_prefix_length;
|
878
|
+
}
|
879
|
+
|
880
|
+
unsigned rep_length =
|
881
|
+
zero_prefix_length + decimal_rep_length + zero_postfix_length;
|
882
|
+
StringBuilder rep_builder(rep_length + 1);
|
883
|
+
rep_builder.AddPadding('0', zero_prefix_length);
|
884
|
+
rep_builder.AddString(decimal_rep);
|
885
|
+
rep_builder.AddPadding('0', zero_postfix_length);
|
886
|
+
char* rep = rep_builder.Finalize();
|
887
|
+
freedtoa(decimal_rep);
|
888
|
+
|
889
|
+
// Create the result string by appending a minus and putting in a
|
890
|
+
// decimal point if needed.
|
891
|
+
unsigned result_size = decimal_point + f + 2;
|
892
|
+
StringBuilder builder(result_size + 1);
|
893
|
+
if (negative) builder.AddCharacter('-');
|
894
|
+
builder.AddSubstring(rep, decimal_point);
|
895
|
+
if (f > 0) {
|
896
|
+
builder.AddCharacter('.');
|
897
|
+
builder.AddSubstring(rep + decimal_point, f);
|
898
|
+
}
|
899
|
+
DeleteArray(rep);
|
900
|
+
return builder.Finalize();
|
901
|
+
}
|
902
|
+
|
903
|
+
|
904
|
+
static char* CreateExponentialRepresentation(char* decimal_rep,
|
905
|
+
int exponent,
|
906
|
+
bool negative,
|
907
|
+
int significant_digits) {
|
908
|
+
bool negative_exponent = false;
|
909
|
+
if (exponent < 0) {
|
910
|
+
negative_exponent = true;
|
911
|
+
exponent = -exponent;
|
912
|
+
}
|
913
|
+
|
914
|
+
// Leave room in the result for appending a minus, for a period, the
|
915
|
+
// letter 'e', a minus or a plus depending on the exponent, and a
|
916
|
+
// three digit exponent.
|
917
|
+
unsigned result_size = significant_digits + 7;
|
918
|
+
StringBuilder builder(result_size + 1);
|
919
|
+
|
920
|
+
if (negative) builder.AddCharacter('-');
|
921
|
+
builder.AddCharacter(decimal_rep[0]);
|
922
|
+
if (significant_digits != 1) {
|
923
|
+
builder.AddCharacter('.');
|
924
|
+
builder.AddString(decimal_rep + 1);
|
925
|
+
int rep_length = StrLength(decimal_rep);
|
926
|
+
builder.AddPadding('0', significant_digits - rep_length);
|
927
|
+
}
|
928
|
+
|
929
|
+
builder.AddCharacter('e');
|
930
|
+
builder.AddCharacter(negative_exponent ? '-' : '+');
|
931
|
+
builder.AddFormatted("%d", exponent);
|
932
|
+
return builder.Finalize();
|
933
|
+
}
|
934
|
+
|
935
|
+
|
936
|
+
|
937
|
+
char* DoubleToExponentialCString(double value, int f) {
|
938
|
+
// f might be -1 to signal that f was undefined in JavaScript.
|
939
|
+
ASSERT(f >= -1 && f <= 20);
|
940
|
+
|
941
|
+
bool negative = false;
|
942
|
+
if (value < 0) {
|
943
|
+
value = -value;
|
944
|
+
negative = true;
|
945
|
+
}
|
946
|
+
|
947
|
+
// Find a sufficiently precise decimal representation of n.
|
948
|
+
int decimal_point;
|
949
|
+
int sign;
|
950
|
+
char* decimal_rep = NULL;
|
951
|
+
if (f == -1) {
|
952
|
+
decimal_rep = dtoa(value, 0, 0, &decimal_point, &sign, NULL);
|
953
|
+
f = StrLength(decimal_rep) - 1;
|
954
|
+
} else {
|
955
|
+
decimal_rep = dtoa(value, 2, f + 1, &decimal_point, &sign, NULL);
|
956
|
+
}
|
957
|
+
int decimal_rep_length = StrLength(decimal_rep);
|
958
|
+
ASSERT(decimal_rep_length > 0);
|
959
|
+
ASSERT(decimal_rep_length <= f + 1);
|
960
|
+
USE(decimal_rep_length);
|
961
|
+
|
962
|
+
int exponent = decimal_point - 1;
|
963
|
+
char* result =
|
964
|
+
CreateExponentialRepresentation(decimal_rep, exponent, negative, f+1);
|
965
|
+
|
966
|
+
freedtoa(decimal_rep);
|
967
|
+
|
968
|
+
return result;
|
969
|
+
}
|
970
|
+
|
971
|
+
|
972
|
+
char* DoubleToPrecisionCString(double value, int p) {
|
973
|
+
ASSERT(p >= 1 && p <= 21);
|
974
|
+
|
975
|
+
bool negative = false;
|
976
|
+
if (value < 0) {
|
977
|
+
value = -value;
|
978
|
+
negative = true;
|
979
|
+
}
|
980
|
+
|
981
|
+
// Find a sufficiently precise decimal representation of n.
|
982
|
+
int decimal_point;
|
983
|
+
int sign;
|
984
|
+
char* decimal_rep = dtoa(value, 2, p, &decimal_point, &sign, NULL);
|
985
|
+
int decimal_rep_length = StrLength(decimal_rep);
|
986
|
+
ASSERT(decimal_rep_length <= p);
|
987
|
+
|
988
|
+
int exponent = decimal_point - 1;
|
989
|
+
|
990
|
+
char* result = NULL;
|
991
|
+
|
992
|
+
if (exponent < -6 || exponent >= p) {
|
993
|
+
result =
|
994
|
+
CreateExponentialRepresentation(decimal_rep, exponent, negative, p);
|
995
|
+
} else {
|
996
|
+
// Use fixed notation.
|
997
|
+
//
|
998
|
+
// Leave room in the result for appending a minus, a period and in
|
999
|
+
// the case where decimal_point is not positive for a zero in
|
1000
|
+
// front of the period.
|
1001
|
+
unsigned result_size = (decimal_point <= 0)
|
1002
|
+
? -decimal_point + p + 3
|
1003
|
+
: p + 2;
|
1004
|
+
StringBuilder builder(result_size + 1);
|
1005
|
+
if (negative) builder.AddCharacter('-');
|
1006
|
+
if (decimal_point <= 0) {
|
1007
|
+
builder.AddString("0.");
|
1008
|
+
builder.AddPadding('0', -decimal_point);
|
1009
|
+
builder.AddString(decimal_rep);
|
1010
|
+
builder.AddPadding('0', p - decimal_rep_length);
|
1011
|
+
} else {
|
1012
|
+
const int m = Min(decimal_rep_length, decimal_point);
|
1013
|
+
builder.AddSubstring(decimal_rep, m);
|
1014
|
+
builder.AddPadding('0', decimal_point - decimal_rep_length);
|
1015
|
+
if (decimal_point < p) {
|
1016
|
+
builder.AddCharacter('.');
|
1017
|
+
const int extra = negative ? 2 : 1;
|
1018
|
+
if (decimal_rep_length > decimal_point) {
|
1019
|
+
const int len = StrLength(decimal_rep + decimal_point);
|
1020
|
+
const int n = Min(len, p - (builder.position() - extra));
|
1021
|
+
builder.AddSubstring(decimal_rep + decimal_point, n);
|
1022
|
+
}
|
1023
|
+
builder.AddPadding('0', extra + (p - builder.position()));
|
1024
|
+
}
|
1025
|
+
}
|
1026
|
+
result = builder.Finalize();
|
1027
|
+
}
|
1028
|
+
|
1029
|
+
freedtoa(decimal_rep);
|
1030
|
+
return result;
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
|
1034
|
+
char* DoubleToRadixCString(double value, int radix) {
|
1035
|
+
ASSERT(radix >= 2 && radix <= 36);
|
1036
|
+
|
1037
|
+
// Character array used for conversion.
|
1038
|
+
static const char chars[] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
1039
|
+
|
1040
|
+
// Buffer for the integer part of the result. 1024 chars is enough
|
1041
|
+
// for max integer value in radix 2. We need room for a sign too.
|
1042
|
+
static const int kBufferSize = 1100;
|
1043
|
+
char integer_buffer[kBufferSize];
|
1044
|
+
integer_buffer[kBufferSize - 1] = '\0';
|
1045
|
+
|
1046
|
+
// Buffer for the decimal part of the result. We only generate up
|
1047
|
+
// to kBufferSize - 1 chars for the decimal part.
|
1048
|
+
char decimal_buffer[kBufferSize];
|
1049
|
+
decimal_buffer[kBufferSize - 1] = '\0';
|
1050
|
+
|
1051
|
+
// Make sure the value is positive.
|
1052
|
+
bool is_negative = value < 0.0;
|
1053
|
+
if (is_negative) value = -value;
|
1054
|
+
|
1055
|
+
// Get the integer part and the decimal part.
|
1056
|
+
double integer_part = floor(value);
|
1057
|
+
double decimal_part = value - integer_part;
|
1058
|
+
|
1059
|
+
// Convert the integer part starting from the back. Always generate
|
1060
|
+
// at least one digit.
|
1061
|
+
int integer_pos = kBufferSize - 2;
|
1062
|
+
do {
|
1063
|
+
integer_buffer[integer_pos--] =
|
1064
|
+
chars[static_cast<int>(modulo(integer_part, radix))];
|
1065
|
+
integer_part /= radix;
|
1066
|
+
} while (integer_part >= 1.0);
|
1067
|
+
// Sanity check.
|
1068
|
+
ASSERT(integer_pos > 0);
|
1069
|
+
// Add sign if needed.
|
1070
|
+
if (is_negative) integer_buffer[integer_pos--] = '-';
|
1071
|
+
|
1072
|
+
// Convert the decimal part. Repeatedly multiply by the radix to
|
1073
|
+
// generate the next char. Never generate more than kBufferSize - 1
|
1074
|
+
// chars.
|
1075
|
+
//
|
1076
|
+
// TODO(1093998): We will often generate a full decimal_buffer of
|
1077
|
+
// chars because hitting zero will often not happen. The right
|
1078
|
+
// solution would be to continue until the string representation can
|
1079
|
+
// be read back and yield the original value. To implement this
|
1080
|
+
// efficiently, we probably have to modify dtoa.
|
1081
|
+
int decimal_pos = 0;
|
1082
|
+
while ((decimal_part > 0.0) && (decimal_pos < kBufferSize - 1)) {
|
1083
|
+
decimal_part *= radix;
|
1084
|
+
decimal_buffer[decimal_pos++] =
|
1085
|
+
chars[static_cast<int>(floor(decimal_part))];
|
1086
|
+
decimal_part -= floor(decimal_part);
|
1087
|
+
}
|
1088
|
+
decimal_buffer[decimal_pos] = '\0';
|
1089
|
+
|
1090
|
+
// Compute the result size.
|
1091
|
+
int integer_part_size = kBufferSize - 2 - integer_pos;
|
1092
|
+
// Make room for zero termination.
|
1093
|
+
unsigned result_size = integer_part_size + decimal_pos;
|
1094
|
+
// If the number has a decimal part, leave room for the period.
|
1095
|
+
if (decimal_pos > 0) result_size++;
|
1096
|
+
// Allocate result and fill in the parts.
|
1097
|
+
StringBuilder builder(result_size + 1);
|
1098
|
+
builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size);
|
1099
|
+
if (decimal_pos > 0) builder.AddCharacter('.');
|
1100
|
+
builder.AddSubstring(decimal_buffer, decimal_pos);
|
1101
|
+
return builder.Finalize();
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
|
1105
|
+
} } // namespace v8::internal
|