libv8 3.10.8.0 → 3.11.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +10 -3
- data/ext/libv8/compiler.rb +46 -0
- data/ext/libv8/extconf.rb +5 -1
- data/ext/libv8/make.rb +13 -0
- data/lib/libv8/version.rb +1 -1
- data/patches/add-freebsd9-and-freebsd10-to-gyp-GetFlavor.patch +11 -0
- data/patches/src_platform-freebsd.cc.patch +10 -0
- data/vendor/v8/ChangeLog +124 -0
- data/vendor/v8/DEPS +27 -0
- data/vendor/v8/Makefile +7 -0
- data/vendor/v8/SConstruct +15 -2
- data/vendor/v8/build/common.gypi +129 -157
- data/vendor/v8/build/gyp_v8 +11 -25
- data/vendor/v8/build/standalone.gypi +9 -3
- data/vendor/v8/include/v8.h +5 -3
- data/vendor/v8/src/SConscript +1 -0
- data/vendor/v8/src/api.cc +4 -33
- data/vendor/v8/src/api.h +2 -2
- data/vendor/v8/src/arm/builtins-arm.cc +5 -4
- data/vendor/v8/src/arm/code-stubs-arm.cc +21 -14
- data/vendor/v8/src/arm/codegen-arm.cc +2 -2
- data/vendor/v8/src/arm/debug-arm.cc +3 -1
- data/vendor/v8/src/arm/full-codegen-arm.cc +3 -102
- data/vendor/v8/src/arm/ic-arm.cc +30 -33
- data/vendor/v8/src/arm/lithium-arm.cc +20 -7
- data/vendor/v8/src/arm/lithium-arm.h +10 -4
- data/vendor/v8/src/arm/lithium-codegen-arm.cc +106 -60
- data/vendor/v8/src/arm/macro-assembler-arm.cc +49 -39
- data/vendor/v8/src/arm/macro-assembler-arm.h +5 -4
- data/vendor/v8/src/arm/regexp-macro-assembler-arm.cc +115 -55
- data/vendor/v8/src/arm/regexp-macro-assembler-arm.h +7 -6
- data/vendor/v8/src/arm/simulator-arm.h +6 -6
- data/vendor/v8/src/arm/stub-cache-arm.cc +64 -19
- data/vendor/v8/src/array.js +7 -3
- data/vendor/v8/src/ast.cc +11 -6
- data/vendor/v8/src/bootstrapper.cc +9 -11
- data/vendor/v8/src/builtins.cc +61 -31
- data/vendor/v8/src/code-stubs.cc +23 -9
- data/vendor/v8/src/code-stubs.h +1 -0
- data/vendor/v8/src/codegen.h +3 -3
- data/vendor/v8/src/compiler.cc +1 -1
- data/vendor/v8/src/contexts.h +2 -18
- data/vendor/v8/src/d8.cc +94 -93
- data/vendor/v8/src/d8.h +1 -1
- data/vendor/v8/src/debug-agent.cc +3 -3
- data/vendor/v8/src/debug.cc +41 -1
- data/vendor/v8/src/debug.h +50 -0
- data/vendor/v8/src/elements-kind.cc +134 -0
- data/vendor/v8/src/elements-kind.h +210 -0
- data/vendor/v8/src/elements.cc +356 -190
- data/vendor/v8/src/elements.h +36 -28
- data/vendor/v8/src/factory.cc +44 -4
- data/vendor/v8/src/factory.h +11 -7
- data/vendor/v8/src/flag-definitions.h +3 -0
- data/vendor/v8/src/frames.h +3 -0
- data/vendor/v8/src/full-codegen.cc +2 -1
- data/vendor/v8/src/func-name-inferrer.h +2 -0
- data/vendor/v8/src/globals.h +3 -0
- data/vendor/v8/src/heap-inl.h +16 -4
- data/vendor/v8/src/heap.cc +38 -32
- data/vendor/v8/src/heap.h +3 -17
- data/vendor/v8/src/hydrogen-instructions.cc +28 -5
- data/vendor/v8/src/hydrogen-instructions.h +142 -44
- data/vendor/v8/src/hydrogen.cc +160 -55
- data/vendor/v8/src/hydrogen.h +2 -0
- data/vendor/v8/src/ia32/assembler-ia32.h +3 -0
- data/vendor/v8/src/ia32/builtins-ia32.cc +5 -4
- data/vendor/v8/src/ia32/code-stubs-ia32.cc +22 -16
- data/vendor/v8/src/ia32/codegen-ia32.cc +2 -2
- data/vendor/v8/src/ia32/debug-ia32.cc +29 -2
- data/vendor/v8/src/ia32/full-codegen-ia32.cc +8 -101
- data/vendor/v8/src/ia32/ic-ia32.cc +23 -19
- data/vendor/v8/src/ia32/lithium-codegen-ia32.cc +126 -80
- data/vendor/v8/src/ia32/lithium-codegen-ia32.h +2 -1
- data/vendor/v8/src/ia32/lithium-ia32.cc +15 -9
- data/vendor/v8/src/ia32/lithium-ia32.h +14 -6
- data/vendor/v8/src/ia32/macro-assembler-ia32.cc +50 -40
- data/vendor/v8/src/ia32/macro-assembler-ia32.h +5 -4
- data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.cc +113 -43
- data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.h +9 -4
- data/vendor/v8/src/ia32/simulator-ia32.h +4 -4
- data/vendor/v8/src/ia32/stub-cache-ia32.cc +52 -14
- data/vendor/v8/src/ic.cc +77 -20
- data/vendor/v8/src/ic.h +18 -2
- data/vendor/v8/src/incremental-marking-inl.h +21 -5
- data/vendor/v8/src/incremental-marking.cc +35 -8
- data/vendor/v8/src/incremental-marking.h +12 -3
- data/vendor/v8/src/isolate.cc +12 -2
- data/vendor/v8/src/isolate.h +1 -1
- data/vendor/v8/src/jsregexp.cc +66 -26
- data/vendor/v8/src/jsregexp.h +60 -31
- data/vendor/v8/src/list-inl.h +8 -0
- data/vendor/v8/src/list.h +3 -0
- data/vendor/v8/src/lithium.cc +5 -2
- data/vendor/v8/src/liveedit.cc +57 -5
- data/vendor/v8/src/mark-compact-inl.h +17 -11
- data/vendor/v8/src/mark-compact.cc +100 -143
- data/vendor/v8/src/mark-compact.h +44 -20
- data/vendor/v8/src/messages.js +131 -99
- data/vendor/v8/src/mips/builtins-mips.cc +5 -4
- data/vendor/v8/src/mips/code-stubs-mips.cc +23 -15
- data/vendor/v8/src/mips/codegen-mips.cc +2 -2
- data/vendor/v8/src/mips/debug-mips.cc +3 -1
- data/vendor/v8/src/mips/full-codegen-mips.cc +4 -102
- data/vendor/v8/src/mips/ic-mips.cc +34 -36
- data/vendor/v8/src/mips/lithium-codegen-mips.cc +116 -68
- data/vendor/v8/src/mips/lithium-mips.cc +20 -7
- data/vendor/v8/src/mips/lithium-mips.h +11 -4
- data/vendor/v8/src/mips/macro-assembler-mips.cc +50 -39
- data/vendor/v8/src/mips/macro-assembler-mips.h +5 -4
- data/vendor/v8/src/mips/regexp-macro-assembler-mips.cc +110 -50
- data/vendor/v8/src/mips/regexp-macro-assembler-mips.h +6 -5
- data/vendor/v8/src/mips/simulator-mips.h +5 -5
- data/vendor/v8/src/mips/stub-cache-mips.cc +66 -20
- data/vendor/v8/src/mksnapshot.cc +5 -1
- data/vendor/v8/src/objects-debug.cc +103 -6
- data/vendor/v8/src/objects-inl.h +215 -116
- data/vendor/v8/src/objects-printer.cc +13 -8
- data/vendor/v8/src/objects.cc +608 -331
- data/vendor/v8/src/objects.h +129 -94
- data/vendor/v8/src/parser.cc +16 -4
- data/vendor/v8/src/platform-freebsd.cc +1 -0
- data/vendor/v8/src/platform-linux.cc +9 -30
- data/vendor/v8/src/platform-posix.cc +28 -7
- data/vendor/v8/src/platform-win32.cc +15 -3
- data/vendor/v8/src/platform.h +2 -1
- data/vendor/v8/src/profile-generator-inl.h +25 -2
- data/vendor/v8/src/profile-generator.cc +300 -822
- data/vendor/v8/src/profile-generator.h +97 -214
- data/vendor/v8/src/regexp-macro-assembler-irregexp.cc +2 -1
- data/vendor/v8/src/regexp-macro-assembler-irregexp.h +2 -2
- data/vendor/v8/src/regexp-macro-assembler-tracer.cc +6 -5
- data/vendor/v8/src/regexp-macro-assembler-tracer.h +1 -1
- data/vendor/v8/src/regexp-macro-assembler.cc +7 -3
- data/vendor/v8/src/regexp-macro-assembler.h +10 -2
- data/vendor/v8/src/regexp.js +6 -0
- data/vendor/v8/src/runtime.cc +265 -212
- data/vendor/v8/src/runtime.h +6 -5
- data/vendor/v8/src/scopes.cc +20 -0
- data/vendor/v8/src/scopes.h +6 -3
- data/vendor/v8/src/spaces.cc +0 -2
- data/vendor/v8/src/string-stream.cc +2 -2
- data/vendor/v8/src/v8-counters.h +0 -2
- data/vendor/v8/src/v8natives.js +2 -2
- data/vendor/v8/src/v8utils.h +6 -3
- data/vendor/v8/src/version.cc +1 -1
- data/vendor/v8/src/x64/assembler-x64.h +2 -1
- data/vendor/v8/src/x64/builtins-x64.cc +5 -4
- data/vendor/v8/src/x64/code-stubs-x64.cc +25 -16
- data/vendor/v8/src/x64/codegen-x64.cc +2 -2
- data/vendor/v8/src/x64/debug-x64.cc +14 -1
- data/vendor/v8/src/x64/disasm-x64.cc +1 -1
- data/vendor/v8/src/x64/full-codegen-x64.cc +10 -106
- data/vendor/v8/src/x64/ic-x64.cc +20 -16
- data/vendor/v8/src/x64/lithium-codegen-x64.cc +156 -79
- data/vendor/v8/src/x64/lithium-codegen-x64.h +2 -1
- data/vendor/v8/src/x64/lithium-x64.cc +18 -8
- data/vendor/v8/src/x64/lithium-x64.h +7 -2
- data/vendor/v8/src/x64/macro-assembler-x64.cc +50 -40
- data/vendor/v8/src/x64/macro-assembler-x64.h +5 -4
- data/vendor/v8/src/x64/regexp-macro-assembler-x64.cc +122 -51
- data/vendor/v8/src/x64/regexp-macro-assembler-x64.h +17 -8
- data/vendor/v8/src/x64/simulator-x64.h +4 -4
- data/vendor/v8/src/x64/stub-cache-x64.cc +55 -17
- data/vendor/v8/test/cctest/cctest.status +1 -0
- data/vendor/v8/test/cctest/test-api.cc +24 -0
- data/vendor/v8/test/cctest/test-func-name-inference.cc +38 -0
- data/vendor/v8/test/cctest/test-heap-profiler.cc +21 -77
- data/vendor/v8/test/cctest/test-heap.cc +164 -3
- data/vendor/v8/test/cctest/test-list.cc +12 -0
- data/vendor/v8/test/cctest/test-mark-compact.cc +5 -5
- data/vendor/v8/test/cctest/test-regexp.cc +14 -8
- data/vendor/v8/test/cctest/testcfg.py +2 -0
- data/vendor/v8/test/mjsunit/accessor-map-sharing.js +176 -0
- data/vendor/v8/test/mjsunit/array-construct-transition.js +3 -3
- data/vendor/v8/test/mjsunit/array-literal-transitions.js +10 -10
- data/vendor/v8/test/mjsunit/big-array-literal.js +3 -0
- data/vendor/v8/test/mjsunit/compiler/inline-construct.js +4 -2
- data/vendor/v8/test/mjsunit/debug-liveedit-stack-padding.js +88 -0
- data/vendor/v8/test/mjsunit/elements-kind.js +4 -4
- data/vendor/v8/test/mjsunit/elements-transition-hoisting.js +2 -2
- data/vendor/v8/test/mjsunit/elements-transition.js +5 -5
- data/vendor/v8/test/mjsunit/error-constructors.js +68 -33
- data/vendor/v8/test/mjsunit/harmony/proxies.js +14 -6
- data/vendor/v8/test/mjsunit/mjsunit.status +1 -0
- data/vendor/v8/test/mjsunit/packed-elements.js +112 -0
- data/vendor/v8/test/mjsunit/regexp-capture-3.js +6 -0
- data/vendor/v8/test/mjsunit/regexp-global.js +132 -0
- data/vendor/v8/test/mjsunit/regexp.js +11 -0
- data/vendor/v8/test/mjsunit/regress/regress-117409.js +52 -0
- data/vendor/v8/test/mjsunit/regress/regress-126412.js +33 -0
- data/vendor/v8/test/mjsunit/regress/regress-128018.js +35 -0
- data/vendor/v8/test/mjsunit/regress/regress-128146.js +33 -0
- data/vendor/v8/test/mjsunit/regress/regress-1639-2.js +4 -1
- data/vendor/v8/test/mjsunit/regress/regress-1639.js +14 -8
- data/vendor/v8/test/mjsunit/regress/regress-1849.js +3 -3
- data/vendor/v8/test/mjsunit/regress/regress-1878.js +2 -2
- data/vendor/v8/test/mjsunit/regress/regress-2071.js +79 -0
- data/vendor/v8/test/mjsunit/regress/regress-2153.js +32 -0
- data/vendor/v8/test/mjsunit/regress/regress-crbug-122271.js +4 -4
- data/vendor/v8/test/mjsunit/regress/regress-crbug-126414.js +32 -0
- data/vendor/v8/test/mjsunit/regress/regress-smi-only-concat.js +2 -2
- data/vendor/v8/test/mjsunit/regress/regress-transcendental.js +49 -0
- data/vendor/v8/test/mjsunit/stack-traces.js +14 -0
- data/vendor/v8/test/mjsunit/unbox-double-arrays.js +4 -3
- data/vendor/v8/test/test262/testcfg.py +6 -1
- data/vendor/v8/tools/check-static-initializers.sh +11 -3
- data/vendor/v8/tools/fuzz-harness.sh +92 -0
- data/vendor/v8/tools/grokdump.py +658 -67
- data/vendor/v8/tools/gyp/v8.gyp +21 -39
- data/vendor/v8/tools/js2c.py +3 -3
- data/vendor/v8/tools/jsmin.py +2 -2
- data/vendor/v8/tools/presubmit.py +2 -1
- data/vendor/v8/tools/test-wrapper-gypbuild.py +25 -11
- metadata +624 -612
data/vendor/v8/src/code-stubs.cc
CHANGED
@@ -262,10 +262,13 @@ void JSEntryStub::FinishCode(Handle<Code> code) {
|
|
262
262
|
void KeyedLoadElementStub::Generate(MacroAssembler* masm) {
|
263
263
|
switch (elements_kind_) {
|
264
264
|
case FAST_ELEMENTS:
|
265
|
-
case
|
265
|
+
case FAST_HOLEY_ELEMENTS:
|
266
|
+
case FAST_SMI_ELEMENTS:
|
267
|
+
case FAST_HOLEY_SMI_ELEMENTS:
|
266
268
|
KeyedLoadStubCompiler::GenerateLoadFastElement(masm);
|
267
269
|
break;
|
268
270
|
case FAST_DOUBLE_ELEMENTS:
|
271
|
+
case FAST_HOLEY_DOUBLE_ELEMENTS:
|
269
272
|
KeyedLoadStubCompiler::GenerateLoadFastDoubleElement(masm);
|
270
273
|
break;
|
271
274
|
case EXTERNAL_BYTE_ELEMENTS:
|
@@ -292,7 +295,9 @@ void KeyedLoadElementStub::Generate(MacroAssembler* masm) {
|
|
292
295
|
void KeyedStoreElementStub::Generate(MacroAssembler* masm) {
|
293
296
|
switch (elements_kind_) {
|
294
297
|
case FAST_ELEMENTS:
|
295
|
-
case
|
298
|
+
case FAST_HOLEY_ELEMENTS:
|
299
|
+
case FAST_SMI_ELEMENTS:
|
300
|
+
case FAST_HOLEY_SMI_ELEMENTS: {
|
296
301
|
KeyedStoreStubCompiler::GenerateStoreFastElement(masm,
|
297
302
|
is_js_array_,
|
298
303
|
elements_kind_,
|
@@ -300,6 +305,7 @@ void KeyedStoreElementStub::Generate(MacroAssembler* masm) {
|
|
300
305
|
}
|
301
306
|
break;
|
302
307
|
case FAST_DOUBLE_ELEMENTS:
|
308
|
+
case FAST_HOLEY_DOUBLE_ELEMENTS:
|
303
309
|
KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(masm,
|
304
310
|
is_js_array_,
|
305
311
|
grow_mode_);
|
@@ -430,24 +436,32 @@ bool ToBooleanStub::Types::CanBeUndetectable() const {
|
|
430
436
|
|
431
437
|
void ElementsTransitionAndStoreStub::Generate(MacroAssembler* masm) {
|
432
438
|
Label fail;
|
439
|
+
ASSERT(!IsFastHoleyElementsKind(from_) || IsFastHoleyElementsKind(to_));
|
433
440
|
if (!FLAG_trace_elements_transitions) {
|
434
|
-
if (to_
|
435
|
-
if (from_
|
436
|
-
ElementsTransitionGenerator::
|
437
|
-
|
441
|
+
if (IsFastSmiOrObjectElementsKind(to_)) {
|
442
|
+
if (IsFastSmiOrObjectElementsKind(from_)) {
|
443
|
+
ElementsTransitionGenerator::
|
444
|
+
GenerateMapChangeElementsTransition(masm);
|
445
|
+
} else if (IsFastDoubleElementsKind(from_)) {
|
446
|
+
ASSERT(!IsFastSmiElementsKind(to_));
|
438
447
|
ElementsTransitionGenerator::GenerateDoubleToObject(masm, &fail);
|
439
448
|
} else {
|
440
449
|
UNREACHABLE();
|
441
450
|
}
|
442
451
|
KeyedStoreStubCompiler::GenerateStoreFastElement(masm,
|
443
452
|
is_jsarray_,
|
444
|
-
|
453
|
+
to_,
|
445
454
|
grow_mode_);
|
446
|
-
} else if (from_
|
447
|
-
|
455
|
+
} else if (IsFastSmiElementsKind(from_) &&
|
456
|
+
IsFastDoubleElementsKind(to_)) {
|
457
|
+
ElementsTransitionGenerator::GenerateSmiToDouble(masm, &fail);
|
448
458
|
KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(masm,
|
449
459
|
is_jsarray_,
|
450
460
|
grow_mode_);
|
461
|
+
} else if (IsFastDoubleElementsKind(from_)) {
|
462
|
+
ASSERT(to_ == FAST_HOLEY_DOUBLE_ELEMENTS);
|
463
|
+
ElementsTransitionGenerator::
|
464
|
+
GenerateMapChangeElementsTransition(masm);
|
451
465
|
} else {
|
452
466
|
UNREACHABLE();
|
453
467
|
}
|
data/vendor/v8/src/code-stubs.h
CHANGED
data/vendor/v8/src/codegen.h
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Copyright
|
1
|
+
// Copyright 2012 the V8 project authors. All rights reserved.
|
2
2
|
// Redistribution and use in source and binary forms, with or without
|
3
3
|
// modification, are permitted provided that the following conditions are
|
4
4
|
// met:
|
@@ -95,8 +95,8 @@ UnaryMathFunction CreateSqrtFunction();
|
|
95
95
|
|
96
96
|
class ElementsTransitionGenerator : public AllStatic {
|
97
97
|
public:
|
98
|
-
static void
|
99
|
-
static void
|
98
|
+
static void GenerateMapChangeElementsTransition(MacroAssembler* masm);
|
99
|
+
static void GenerateSmiToDouble(MacroAssembler* masm, Label* fail);
|
100
100
|
static void GenerateDoubleToObject(MacroAssembler* masm, Label* fail);
|
101
101
|
|
102
102
|
private:
|
data/vendor/v8/src/compiler.cc
CHANGED
@@ -118,7 +118,7 @@ bool CompilationInfo::ShouldSelfOptimize() {
|
|
118
118
|
FLAG_crankshaft &&
|
119
119
|
!function()->flags()->Contains(kDontSelfOptimize) &&
|
120
120
|
!function()->flags()->Contains(kDontOptimize) &&
|
121
|
-
function()->scope()->
|
121
|
+
function()->scope()->AllowsLazyRecompilation() &&
|
122
122
|
(shared_info().is_null() || !shared_info()->optimization_disabled());
|
123
123
|
}
|
124
124
|
|
data/vendor/v8/src/contexts.h
CHANGED
@@ -106,9 +106,7 @@ enum BindingFlags {
|
|
106
106
|
V(OBJECT_FUNCTION_INDEX, JSFunction, object_function) \
|
107
107
|
V(INTERNAL_ARRAY_FUNCTION_INDEX, JSFunction, internal_array_function) \
|
108
108
|
V(ARRAY_FUNCTION_INDEX, JSFunction, array_function) \
|
109
|
-
V(
|
110
|
-
V(DOUBLE_JS_ARRAY_MAP_INDEX, Object, double_js_array_map) \
|
111
|
-
V(OBJECT_JS_ARRAY_MAP_INDEX, Object, object_js_array_map) \
|
109
|
+
V(JS_ARRAY_MAPS_INDEX, Object, js_array_maps) \
|
112
110
|
V(DATE_FUNCTION_INDEX, JSFunction, date_function) \
|
113
111
|
V(JSON_OBJECT_INDEX, JSObject, json_object) \
|
114
112
|
V(REGEXP_FUNCTION_INDEX, JSFunction, regexp_function) \
|
@@ -248,9 +246,7 @@ class Context: public FixedArray {
|
|
248
246
|
OBJECT_FUNCTION_INDEX,
|
249
247
|
INTERNAL_ARRAY_FUNCTION_INDEX,
|
250
248
|
ARRAY_FUNCTION_INDEX,
|
251
|
-
|
252
|
-
DOUBLE_JS_ARRAY_MAP_INDEX,
|
253
|
-
OBJECT_JS_ARRAY_MAP_INDEX,
|
249
|
+
JS_ARRAY_MAPS_INDEX,
|
254
250
|
DATE_FUNCTION_INDEX,
|
255
251
|
JSON_OBJECT_INDEX,
|
256
252
|
REGEXP_FUNCTION_INDEX,
|
@@ -373,18 +369,6 @@ class Context: public FixedArray {
|
|
373
369
|
Object* OptimizedFunctionsListHead();
|
374
370
|
void ClearOptimizedFunctions();
|
375
371
|
|
376
|
-
static int GetContextMapIndexFromElementsKind(
|
377
|
-
ElementsKind elements_kind) {
|
378
|
-
if (elements_kind == FAST_DOUBLE_ELEMENTS) {
|
379
|
-
return Context::DOUBLE_JS_ARRAY_MAP_INDEX;
|
380
|
-
} else if (elements_kind == FAST_ELEMENTS) {
|
381
|
-
return Context::OBJECT_JS_ARRAY_MAP_INDEX;
|
382
|
-
} else {
|
383
|
-
ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS);
|
384
|
-
return Context::SMI_JS_ARRAY_MAP_INDEX;
|
385
|
-
}
|
386
|
-
}
|
387
|
-
|
388
372
|
#define GLOBAL_CONTEXT_FIELD_ACCESSORS(index, type, name) \
|
389
373
|
void set_##name(type* value) { \
|
390
374
|
ASSERT(IsGlobalContext()); \
|
data/vendor/v8/src/d8.cc
CHANGED
@@ -26,7 +26,8 @@
|
|
26
26
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
27
|
|
28
28
|
|
29
|
-
|
29
|
+
// Defined when linking against shared lib on Windows.
|
30
|
+
#if defined(USING_V8_SHARED) && !defined(V8_SHARED)
|
30
31
|
#define V8_SHARED
|
31
32
|
#endif
|
32
33
|
|
@@ -315,8 +316,8 @@ static size_t convertToUint(Local<Value> value_in, TryCatch* try_catch) {
|
|
315
316
|
}
|
316
317
|
|
317
318
|
|
318
|
-
const char
|
319
|
-
const char
|
319
|
+
const char kArrayBufferMarkerPropName[] = "d8::_is_array_buffer_";
|
320
|
+
const char kArrayBufferReferencePropName[] = "d8::_array_buffer_ref_";
|
320
321
|
|
321
322
|
static const int kExternalArrayAllocationHeaderSize = 2;
|
322
323
|
|
@@ -333,128 +334,119 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
|
|
333
334
|
element_size == 8);
|
334
335
|
if (args.Length() == 0) {
|
335
336
|
return ThrowException(
|
336
|
-
String::New("Array constructor must have at least one "
|
337
|
-
"parameter."));
|
337
|
+
String::New("Array constructor must have at least one parameter."));
|
338
338
|
}
|
339
339
|
bool first_arg_is_array_buffer =
|
340
340
|
args[0]->IsObject() &&
|
341
|
-
args[0]->ToObject()->
|
342
|
-
String::New(kArrayBufferMarkerPropName))
|
341
|
+
!args[0]->ToObject()->GetHiddenValue(
|
342
|
+
String::New(kArrayBufferMarkerPropName)).IsEmpty();
|
343
343
|
// Currently, only the following constructors are supported:
|
344
|
+
// ArrayBuffer(unsigned long length)
|
344
345
|
// TypedArray(unsigned long length)
|
345
346
|
// TypedArray(ArrayBuffer buffer,
|
346
347
|
// optional unsigned long byteOffset,
|
347
348
|
// optional unsigned long length)
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
"have 1-3 parameters."));
|
352
|
-
}
|
353
|
-
|
354
|
-
Local<Value> length_value = (args.Length() < 3)
|
355
|
-
? (first_arg_is_array_buffer
|
356
|
-
? args[0]->ToObject()->Get(String::New("length"))
|
357
|
-
: args[0])
|
358
|
-
: args[2];
|
359
|
-
size_t length = convertToUint(length_value, &try_catch);
|
360
|
-
if (try_catch.HasCaught()) return try_catch.Exception();
|
361
|
-
|
349
|
+
size_t length;
|
350
|
+
size_t byteLength;
|
351
|
+
size_t byteOffset;
|
362
352
|
void* data = NULL;
|
363
|
-
size_t offset = 0;
|
364
|
-
|
365
353
|
Handle<Object> array = Object::New();
|
366
|
-
if (
|
367
|
-
|
368
|
-
data = derived_from->GetIndexedPropertiesExternalArrayData();
|
369
|
-
|
370
|
-
size_t array_buffer_length = convertToUint(
|
371
|
-
derived_from->Get(String::New("length")),
|
372
|
-
&try_catch);
|
354
|
+
if (is_array_buffer_construct) {
|
355
|
+
byteLength = convertToUint(args[0], &try_catch);
|
373
356
|
if (try_catch.HasCaught()) return try_catch.Exception();
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
357
|
+
byteOffset = 0;
|
358
|
+
length = byteLength;
|
359
|
+
|
360
|
+
array->SetHiddenValue(String::New(kArrayBufferMarkerPropName), True());
|
361
|
+
} else if (first_arg_is_array_buffer) {
|
362
|
+
Handle<Object> buffer = args[0]->ToObject();
|
363
|
+
data = buffer->GetIndexedPropertiesExternalArrayData();
|
364
|
+
byteLength =
|
365
|
+
convertToUint(buffer->Get(String::New("byteLength")), &try_catch);
|
366
|
+
if (try_catch.HasCaught()) return try_catch.Exception();
|
367
|
+
if (data == NULL && byteLength != 0) {
|
368
|
+
return ThrowException(String::New("ArrayBuffer does not have data"));
|
378
369
|
}
|
379
370
|
|
380
|
-
if (args.Length()
|
381
|
-
|
371
|
+
if (args.Length() < 2 || args[1]->IsUndefined()) {
|
372
|
+
byteOffset = 0;
|
373
|
+
} else {
|
374
|
+
byteOffset = convertToUint(args[1], &try_catch);
|
382
375
|
if (try_catch.HasCaught()) return try_catch.Exception();
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
if (
|
376
|
+
if (byteOffset > byteLength) {
|
377
|
+
return ThrowException(String::New("byteOffset out of bounds"));
|
378
|
+
}
|
379
|
+
if (byteOffset % element_size != 0) {
|
387
380
|
return ThrowException(
|
388
|
-
String::New("
|
381
|
+
String::New("byteOffset must be multiple of element_size"));
|
389
382
|
}
|
390
383
|
}
|
391
384
|
|
392
|
-
if (
|
393
|
-
|
394
|
-
String::New("byteOffset must be less than ArrayBuffer length."));
|
395
|
-
}
|
396
|
-
|
397
|
-
if (args.Length() == 2) {
|
398
|
-
// If length is not explicitly specified, the length of the ArrayBuffer
|
399
|
-
// minus the byteOffset must be a multiple of the element size of the
|
400
|
-
// specific type, or an exception is raised.
|
401
|
-
length = array_buffer_length - offset;
|
402
|
-
}
|
403
|
-
|
404
|
-
if (args.Length() != 3) {
|
405
|
-
if (length % element_size != 0) {
|
385
|
+
if (args.Length() < 3 || args[2]->IsUndefined()) {
|
386
|
+
if (byteLength % element_size != 0) {
|
406
387
|
return ThrowException(
|
407
|
-
String::New("
|
408
|
-
"multiple of the element size"));
|
388
|
+
String::New("buffer size must be multiple of element_size"));
|
409
389
|
}
|
410
|
-
length
|
390
|
+
length = (byteLength - byteOffset) / element_size;
|
391
|
+
} else {
|
392
|
+
length = convertToUint(args[2], &try_catch);
|
393
|
+
if (try_catch.HasCaught()) return try_catch.Exception();
|
411
394
|
}
|
412
395
|
|
413
|
-
|
414
|
-
|
415
|
-
if (offset + (length * element_size) > array_buffer_length) {
|
416
|
-
return ThrowException(
|
417
|
-
String::New("length references an area beyond the end of the "
|
418
|
-
"ArrayBuffer"));
|
396
|
+
if (byteOffset + length * element_size > byteLength) {
|
397
|
+
return ThrowException(String::New("length out of bounds"));
|
419
398
|
}
|
399
|
+
byteLength = byteOffset + length * element_size;
|
420
400
|
|
421
401
|
// Hold a reference to the ArrayBuffer so its buffer doesn't get collected.
|
422
|
-
array->
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
402
|
+
array->SetHiddenValue(
|
403
|
+
String::New(kArrayBufferReferencePropName), args[0]);
|
404
|
+
} else {
|
405
|
+
length = convertToUint(args[0], &try_catch);
|
406
|
+
byteLength = length * element_size;
|
407
|
+
byteOffset = 0;
|
427
408
|
}
|
428
409
|
|
429
410
|
Persistent<Object> persistent_array = Persistent<Object>::New(array);
|
430
|
-
if (data == NULL &&
|
431
|
-
|
411
|
+
if (data == NULL && byteLength != 0) {
|
412
|
+
ASSERT(byteOffset == 0);
|
413
|
+
// Prepend the size of the allocated chunk to the data itself.
|
414
|
+
int total_size =
|
415
|
+
byteLength + kExternalArrayAllocationHeaderSize * sizeof(size_t);
|
432
416
|
static const int kMaxSize = 0x7fffffff;
|
433
|
-
|
417
|
+
// Make sure the total size fits into a (signed) int.
|
418
|
+
if (total_size > kMaxSize) {
|
434
419
|
return ThrowException(String::New("Array exceeds maximum size (2G)"));
|
435
420
|
}
|
436
|
-
// Prepend the size of the allocated chunk to the data itself.
|
437
|
-
int total_size = length * element_size +
|
438
|
-
kExternalArrayAllocationHeaderSize * sizeof(size_t);
|
439
421
|
data = malloc(total_size);
|
440
422
|
if (data == NULL) {
|
441
423
|
return ThrowException(String::New("Memory allocation failed."));
|
442
424
|
}
|
443
425
|
*reinterpret_cast<size_t*>(data) = total_size;
|
444
426
|
data = reinterpret_cast<size_t*>(data) + kExternalArrayAllocationHeaderSize;
|
445
|
-
memset(data, 0,
|
427
|
+
memset(data, 0, byteLength);
|
446
428
|
V8::AdjustAmountOfExternalAllocatedMemory(total_size);
|
447
429
|
}
|
448
430
|
persistent_array.MakeWeak(data, ExternalArrayWeakCallback);
|
449
431
|
persistent_array.MarkIndependent();
|
450
432
|
|
451
433
|
array->SetIndexedPropertiesToExternalArrayData(
|
452
|
-
reinterpret_cast<uint8_t*>(data) +
|
434
|
+
reinterpret_cast<uint8_t*>(data) + byteOffset, type,
|
453
435
|
static_cast<int>(length));
|
454
|
-
array->Set(String::New("
|
455
|
-
Int32::New(static_cast<int32_t>(
|
456
|
-
|
457
|
-
|
436
|
+
array->Set(String::New("byteLength"),
|
437
|
+
Int32::New(static_cast<int32_t>(byteLength)), ReadOnly);
|
438
|
+
if (!is_array_buffer_construct) {
|
439
|
+
array->Set(String::New("byteOffset"),
|
440
|
+
Int32::New(static_cast<int32_t>(byteOffset)), ReadOnly);
|
441
|
+
array->Set(String::New("length"),
|
442
|
+
Int32::New(static_cast<int32_t>(length)), ReadOnly);
|
443
|
+
array->Set(String::New("BYTES_PER_ELEMENT"),
|
444
|
+
Int32::New(static_cast<int32_t>(element_size)));
|
445
|
+
// We currently support 'buffer' property only if constructed from a buffer.
|
446
|
+
if (first_arg_is_array_buffer) {
|
447
|
+
array->Set(String::New("buffer"), args[0], ReadOnly);
|
448
|
+
}
|
449
|
+
}
|
458
450
|
return array;
|
459
451
|
}
|
460
452
|
|
@@ -463,8 +455,8 @@ void Shell::ExternalArrayWeakCallback(Persistent<Value> object, void* data) {
|
|
463
455
|
HandleScope scope;
|
464
456
|
Handle<String> prop_name = String::New(kArrayBufferReferencePropName);
|
465
457
|
Handle<Object> converted_object = object->ToObject();
|
466
|
-
Local<Value> prop_value = converted_object->
|
467
|
-
if (data != NULL &&
|
458
|
+
Local<Value> prop_value = converted_object->GetHiddenValue(prop_name);
|
459
|
+
if (data != NULL && prop_value.IsEmpty()) {
|
468
460
|
data = reinterpret_cast<size_t*>(data) - kExternalArrayAllocationHeaderSize;
|
469
461
|
V8::AdjustAmountOfExternalAllocatedMemory(
|
470
462
|
-static_cast<int>(*reinterpret_cast<size_t*>(data)));
|
@@ -822,8 +814,8 @@ Handle<ObjectTemplate> Shell::CreateGlobalTemplate() {
|
|
822
814
|
global_template->Set(String::New("print"), FunctionTemplate::New(Print));
|
823
815
|
global_template->Set(String::New("write"), FunctionTemplate::New(Write));
|
824
816
|
global_template->Set(String::New("read"), FunctionTemplate::New(Read));
|
825
|
-
global_template->Set(String::New("
|
826
|
-
FunctionTemplate::New(
|
817
|
+
global_template->Set(String::New("readbuffer"),
|
818
|
+
FunctionTemplate::New(ReadBuffer));
|
827
819
|
global_template->Set(String::New("readline"),
|
828
820
|
FunctionTemplate::New(ReadLine));
|
829
821
|
global_template->Set(String::New("load"), FunctionTemplate::New(Load));
|
@@ -1042,20 +1034,29 @@ static char* ReadChars(const char* name, int* size_out) {
|
|
1042
1034
|
}
|
1043
1035
|
|
1044
1036
|
|
1045
|
-
Handle<Value> Shell::
|
1037
|
+
Handle<Value> Shell::ReadBuffer(const Arguments& args) {
|
1046
1038
|
String::Utf8Value filename(args[0]);
|
1047
|
-
int
|
1039
|
+
int length;
|
1048
1040
|
if (*filename == NULL) {
|
1049
1041
|
return ThrowException(String::New("Error loading file"));
|
1050
1042
|
}
|
1051
|
-
char*
|
1052
|
-
if (
|
1043
|
+
char* data = ReadChars(*filename, &length);
|
1044
|
+
if (data == NULL) {
|
1053
1045
|
return ThrowException(String::New("Error reading file"));
|
1054
1046
|
}
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1047
|
+
|
1048
|
+
Handle<Object> buffer = Object::New();
|
1049
|
+
buffer->SetHiddenValue(String::New(kArrayBufferMarkerPropName), True());
|
1050
|
+
|
1051
|
+
Persistent<Object> persistent_buffer = Persistent<Object>::New(buffer);
|
1052
|
+
persistent_buffer.MakeWeak(data, ExternalArrayWeakCallback);
|
1053
|
+
persistent_buffer.MarkIndependent();
|
1054
|
+
|
1055
|
+
buffer->SetIndexedPropertiesToExternalArrayData(
|
1056
|
+
reinterpret_cast<uint8_t*>(data), kExternalUnsignedByteArray, length);
|
1057
|
+
buffer->Set(String::New("byteLength"),
|
1058
|
+
Int32::New(static_cast<int32_t>(length)), ReadOnly);
|
1059
|
+
return buffer;
|
1059
1060
|
}
|
1060
1061
|
|
1061
1062
|
|
data/vendor/v8/src/d8.h
CHANGED
@@ -307,7 +307,7 @@ class Shell : public i::AllStatic {
|
|
307
307
|
static Handle<Value> EnableProfiler(const Arguments& args);
|
308
308
|
static Handle<Value> DisableProfiler(const Arguments& args);
|
309
309
|
static Handle<Value> Read(const Arguments& args);
|
310
|
-
static Handle<Value>
|
310
|
+
static Handle<Value> ReadBuffer(const Arguments& args);
|
311
311
|
static Handle<String> ReadFromStdin();
|
312
312
|
static Handle<Value> ReadLine(const Arguments& args) {
|
313
313
|
return ReadFromStdin();
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Copyright
|
1
|
+
// Copyright 2012 the V8 project authors. All rights reserved.
|
2
2
|
// Redistribution and use in source and binary forms, with or without
|
3
3
|
// modification, are permitted provided that the following conditions are
|
4
4
|
// met:
|
@@ -247,7 +247,7 @@ SmartArrayPointer<char> DebuggerAgentUtil::ReceiveMessage(const Socket* conn) {
|
|
247
247
|
while (!(c == '\n' && prev_c == '\r')) {
|
248
248
|
prev_c = c;
|
249
249
|
received = conn->Receive(&c, 1);
|
250
|
-
if (received
|
250
|
+
if (received == 0) {
|
251
251
|
PrintF("Error %d\n", Socket::LastError());
|
252
252
|
return SmartArrayPointer<char>();
|
253
253
|
}
|
@@ -454,7 +454,7 @@ int DebuggerAgentUtil::ReceiveAll(const Socket* conn, char* data, int len) {
|
|
454
454
|
int total_received = 0;
|
455
455
|
while (total_received < len) {
|
456
456
|
int received = conn->Receive(data + total_received, len - total_received);
|
457
|
-
if (received
|
457
|
+
if (received == 0) {
|
458
458
|
return total_received;
|
459
459
|
}
|
460
460
|
total_received += received;
|