Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

176
deps/v8/test/mjsunit/tools/codemap.mjs vendored Normal file
View File

@ -0,0 +1,176 @@
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import { CodeMap, CodeEntry } from "../../../tools/codemap.mjs";
function assertEntry(codeMap, expected_name, addr) {
var entry = codeMap.findEntry(addr);
assertNotNull(entry, 'no entry at ' + addr.toString(16));
assertEquals(expected_name, entry.name, 'at ' + addr.toString(16));
};
function assertNoEntry(codeMap, addr) {
assertNull(codeMap.findEntry(addr), 'at ' + addr.toString(16));
};
(function testLibrariesAndStaticCode() {
var codeMap = new CodeMap();
codeMap.addLibrary(0x1500, new CodeEntry(0x3000, 'lib1'));
codeMap.addLibrary(0x15500, new CodeEntry(0x5000, 'lib2'));
codeMap.addLibrary(0x155500, new CodeEntry(0x10000, 'lib3'));
assertNoEntry(codeMap, 0);
assertNoEntry(codeMap, 0x1500 - 1);
assertEntry(codeMap, 'lib1', 0x1500);
assertEntry(codeMap, 'lib1', 0x1500 + 0x100);
assertEntry(codeMap, 'lib1', 0x1500 + 0x1000);
assertEntry(codeMap, 'lib1', 0x1500 + 0x3000 - 1);
assertNoEntry(codeMap, 0x1500 + 0x3000);
assertNoEntry(codeMap, 0x15500 - 1);
assertEntry(codeMap, 'lib2', 0x15500);
assertEntry(codeMap, 'lib2', 0x15500 + 0x100);
assertEntry(codeMap, 'lib2', 0x15500 + 0x1000);
assertEntry(codeMap, 'lib2', 0x15500 + 0x5000 - 1);
assertNoEntry(codeMap, 0x15500 + 0x5000);
assertNoEntry(codeMap, 0x155500 - 1);
assertEntry(codeMap, 'lib3', 0x155500);
assertEntry(codeMap, 'lib3', 0x155500 + 0x100);
assertEntry(codeMap, 'lib3', 0x155500 + 0x1000);
assertEntry(codeMap, 'lib3', 0x155500 + 0x10000 - 1);
assertNoEntry(codeMap, 0x155500 + 0x10000);
assertNoEntry(codeMap, 0xFFFFFFFF);
codeMap.addStaticCode(0x1510, new CodeEntry(0x30, 'lib1-f1'));
codeMap.addStaticCode(0x1600, new CodeEntry(0x50, 'lib1-f2'));
codeMap.addStaticCode(0x15520, new CodeEntry(0x100, 'lib2-f1'));
assertEntry(codeMap, 'lib1', 0x1500);
assertEntry(codeMap, 'lib1', 0x1510 - 1);
assertEntry(codeMap, 'lib1-f1', 0x1510);
assertEntry(codeMap, 'lib1-f1', 0x1510 + 0x15);
assertEntry(codeMap, 'lib1-f1', 0x1510 + 0x30 - 1);
assertEntry(codeMap, 'lib1', 0x1510 + 0x30);
assertEntry(codeMap, 'lib1', 0x1600 - 1);
assertEntry(codeMap, 'lib1-f2', 0x1600);
assertEntry(codeMap, 'lib1-f2', 0x1600 + 0x30);
assertEntry(codeMap, 'lib1-f2', 0x1600 + 0x50 - 1);
assertEntry(codeMap, 'lib1', 0x1600 + 0x50);
assertEntry(codeMap, 'lib2', 0x15500);
assertEntry(codeMap, 'lib2', 0x15520 - 1);
assertEntry(codeMap, 'lib2-f1', 0x15520);
assertEntry(codeMap, 'lib2-f1', 0x15520 + 0x80);
assertEntry(codeMap, 'lib2-f1', 0x15520 + 0x100 - 1);
assertEntry(codeMap, 'lib2', 0x15520 + 0x100);
})();
(function testDynamicCode() {
var codeMap = new CodeMap();
codeMap.addCode(0x1500, new CodeEntry(0x200, 'code1'));
codeMap.addCode(0x1700, new CodeEntry(0x100, 'code2'));
codeMap.addCode(0x1900, new CodeEntry(0x50, 'code3'));
codeMap.addCode(0x1950, new CodeEntry(0x10, 'code4'));
assertNoEntry(codeMap, 0);
assertNoEntry(codeMap, 0x1500 - 1);
assertEntry(codeMap, 'code1', 0x1500);
assertEntry(codeMap, 'code1', 0x1500 + 0x100);
assertEntry(codeMap, 'code1', 0x1500 + 0x200 - 1);
assertEntry(codeMap, 'code2', 0x1700);
assertEntry(codeMap, 'code2', 0x1700 + 0x50);
assertEntry(codeMap, 'code2', 0x1700 + 0x100 - 1);
assertNoEntry(codeMap, 0x1700 + 0x100);
assertNoEntry(codeMap, 0x1900 - 1);
assertEntry(codeMap, 'code3', 0x1900);
assertEntry(codeMap, 'code3', 0x1900 + 0x28);
assertEntry(codeMap, 'code4', 0x1950);
assertEntry(codeMap, 'code4', 0x1950 + 0x7);
assertEntry(codeMap, 'code4', 0x1950 + 0x10 - 1);
assertNoEntry(codeMap, 0x1950 + 0x10);
assertNoEntry(codeMap, 0xFFFFFFFF);
})();
(function testCodeMovesAndDeletions() {
var codeMap = new CodeMap();
codeMap.addCode(0x1500, new CodeEntry(0x200, 'code1'));
codeMap.addCode(0x1700, new CodeEntry(0x100, 'code2'));
assertEntry(codeMap, 'code1', 0x1500);
assertEntry(codeMap, 'code2', 0x1700);
codeMap.moveCode(0x1500, 0x1800);
assertNoEntry(codeMap, 0x1500);
assertEntry(codeMap, 'code2', 0x1700);
assertEntry(codeMap, 'code1', 0x1800);
codeMap.deleteCode(0x1700);
assertNoEntry(codeMap, 0x1700);
assertEntry(codeMap, 'code1', 0x1800);
})();
(function testDynamicNamesDuplicates() {
var codeMap = new CodeMap();
// Code entries with same names but different addresses.
codeMap.addCode(0x1500, new CodeEntry(0x200, 'code'));
codeMap.addCode(0x1700, new CodeEntry(0x100, 'code'));
assertEntry(codeMap, 'code', 0x1500);
assertEntry(codeMap, 'code {1}', 0x1700);
// Test name stability.
assertEntry(codeMap, 'code', 0x1500);
assertEntry(codeMap, 'code {1}', 0x1700);
})();
(function testStaticEntriesExport() {
var codeMap = new CodeMap();
codeMap.addStaticCode(0x1500, new CodeEntry(0x3000, 'lib1'));
codeMap.addStaticCode(0x15500, new CodeEntry(0x5000, 'lib2'));
codeMap.addStaticCode(0x155500, new CodeEntry(0x10000, 'lib3'));
var allStatics = codeMap.getAllStaticEntries();
allStatics = allStatics.map(String);
allStatics.sort();
assertEquals(['lib1: 3000', 'lib2: 5000', 'lib3: 10000'], allStatics);
})();
(function testDynamicEntriesExport() {
var codeMap = new CodeMap();
codeMap.addCode(0x1500, new CodeEntry(0x200, 'code1'));
codeMap.addCode(0x1700, new CodeEntry(0x100, 'code2'));
codeMap.addCode(0x1900, new CodeEntry(0x50, 'code3'));
var allDynamics = codeMap.getAllDynamicEntries();
allDynamics = allDynamics.map(String);
allDynamics.sort();
assertEquals(['code1: 200', 'code2: 100', 'code3: 50'], allDynamics);
codeMap.deleteCode(0x1700);
var allDynamics2 = codeMap.getAllDynamicEntries();
allDynamics2 = allDynamics2.map(String);
allDynamics2.sort();
assertEquals(['code1: 200', 'code3: 50'], allDynamics2);
codeMap.deleteCode(0x1500);
var allDynamics3 = codeMap.getAllDynamicEntries();
assertEquals(['code3: 50'], allDynamics3.map(String));
})();

View File

@ -0,0 +1,30 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Disable liftoff to make sure we generate turbofan traces.
// Flags: --no-liftoff
// Flags: --trace-turbo --trace-turbo-graph
// Flags: --trace-turbo-cfg-file=test/mjsunit/tools/turbo.cfg
// Flags: --trace-turbo-path=test/mjsunit/tools
// Only trace the wasm functions:
// Flags: --trace-turbo-filter=wasm*
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
// The idea behind this test is to make sure we do not crash when using the
// --trace-turbo flag given different sort of inputs.
(function testWASM() {
let builder = new WasmModuleBuilder();
builder.addFunction("add", kSig_i_ii)
.addBody([kExprLocalGet, 0,
kExprLocalGet, 1,
kExprI32Add])
.exportFunc();
let instance = builder.instantiate();
instance.exports.add(21, 21);
})();

View File

@ -0,0 +1,23 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --trace-turbo --trace-turbo-graph
// Flags: --trace-turbo-cfg-file=test/mjsunit/tools/turbo.cfg
// Flags: --trace-turbo-path=test/mjsunit/tools
// Only trace the "add" function:
// Flags: --trace-turbo-filter=add
// The idea behind this test is to make sure we do not crash when using the
// --trace-turbo flag given different sort of inputs.
(function testOptimizedJS() {
function add(a, b) {
return a + b;
};
%PrepareFunctionForOptimization(add);
add(21, 21);
%OptimizeFunctionOnNextCall(add);
add(20, 22);
})();

View File

@ -0,0 +1,58 @@
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import { ConsArray } from "../../../tools/consarray.mjs";
var arr1 = new ConsArray();
assertTrue(arr1.atEnd());
arr1.concat([]);
assertTrue(arr1.atEnd());
arr1.concat([1]);
assertFalse(arr1.atEnd());
assertEquals(1, arr1.next());
assertTrue(arr1.atEnd());
arr1.concat([2, 3, 4]);
arr1.concat([5]);
arr1.concat([]);
arr1.concat([6, 7]);
assertFalse(arr1.atEnd());
assertEquals(2, arr1.next());
assertFalse(arr1.atEnd());
assertEquals(3, arr1.next());
assertFalse(arr1.atEnd());
assertEquals(4, arr1.next());
assertFalse(arr1.atEnd());
assertEquals(5, arr1.next());
assertFalse(arr1.atEnd());
assertEquals(6, arr1.next());
assertFalse(arr1.atEnd());
assertEquals(7, arr1.next());
assertTrue(arr1.atEnd());

View File

@ -0,0 +1,89 @@
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import { CsvParser } from "../../../tools/csvparser.mjs";
var parser = new CsvParser();
assertEquals(
[],
parser.parseLine(''));
assertEquals(
['', ''],
parser.parseLine(','));
assertEquals(
['1997','Ford','E350'],
parser.parseLine('1997,Ford,E350'));
assertEquals(
['"', '\'', ',', '\n'],
parser.parseLine('",\',\\x2c,\\x0a'));
assertEquals(
['"1997"','Ford','E350'],
parser.parseLine('"1997",Ford,E350'));
assertEquals(
['1997', 'Ford', 'E350', 'Super', ' luxurious truck'],
parser.parseLine('1997,Ford,E350,Super, luxurious truck'));
assertEquals(
['1997','Ford','E350','Super "luxurious" truck'],
parser.parseLine('1997,Ford,E350,Super "luxurious" truck'));
assertEquals(
['1997','Ford','E350','Super "luxurious" "truck"'],
parser.parseLine('1997,Ford,E350,Super "luxurious" "truck"'));
assertEquals(
['1997','Ford','E350','Super "luxurious""truck"'],
parser.parseLine('1997,Ford,E350,Super "luxurious""truck"'));
assertEquals(
['shared-library','/lib/ld-2.3.6.so','0x489a2000','0x489b7000'],
parser.parseLine('shared-library,/lib/ld-2.3.6.so,0x489a2000,0x489b7000'));
assertEquals(
['code-creation','LazyCompile','0xf6fe2d20','1201','APPLY_PREPARE native runtime.js:165'],
parser.parseLine('code-creation,LazyCompile,0xf6fe2d20,1201,APPLY_PREPARE native runtime.js:165'));
assertEquals(
['code-creation','LazyCompile','0xf6fe4bc0','282',' native v8natives.js:69'],
parser.parseLine('code-creation,LazyCompile,0xf6fe4bc0,282, native v8natives.js:69'));
assertEquals(
['code-creation','RegExp','0xf6c21c00','826','NccyrJroXvg\\/([^,]*)'],
parser.parseLine('code-creation,RegExp,0xf6c21c00,826,NccyrJroXvg\\x5C/([^\\x2C]*)'));
assertEquals(
['code-creation','Function','0x42f0a0','163','""'],
parser.parseLine('code-creation,Function,0x42f0a0,163,""'));
assertEquals(
['foo C:\\Users\\someuser\\script.js:1:13'],
parser.parseLine('foo C:\\\\Users\\\\someuser\\\\script.js:1:13'));

56
deps/v8/test/mjsunit/tools/dumpcpp.mjs vendored Normal file
View File

@ -0,0 +1,56 @@
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {
CppProcessor, LinuxCppEntriesProvider
} from "../../../tools/dumpcpp.mjs" ;
await (async function testProcessSharedLibrary() {
var oldLoadSymbols = LinuxCppEntriesProvider.prototype.loadSymbols;
LinuxCppEntriesProvider.prototype.loadSymbols = function(libName) {
this.symbols = [[
'00000100 00000001 t v8::internal::Runtime_StringReplaceRegExpWithString(v8::internal::Arguments)',
'00000110 00000001 T v8::internal::Runtime::GetElementOrCharAt(v8::internal::Handle<v8::internal::Object>, unsigned int)',
'00000120 00000001 t v8::internal::Runtime_DebugGetPropertyDetails(v8::internal::Arguments)',
'00000130 00000001 W v8::internal::RegExpMacroAssembler::CheckPosition(int, v8::internal::Label*)'
].join('\n'), ''];
};
var testCppProcessor = new CppProcessor(new LinuxCppEntriesProvider(),
false, false);
await testCppProcessor.processSharedLibrary(
'/usr/local/google/home/lpy/v8/out/native/d8',
0x00000100, 0x00000400, 0);
var staticEntries = testCppProcessor.codeMap_.getAllStaticEntriesWithAddresses();
var total = staticEntries.length;
assertEquals(total, 3);
assertEquals(staticEntries[0],
[288,{size:1,
name:'v8::internal::Runtime_DebugGetPropertyDetails(v8::internal::Arguments)',
type:'CPP',
nameUpdated_:false,
source: undefined,
}
]);
assertEquals(staticEntries[1],
[272,{size:1,
name:'v8::internal::Runtime::GetElementOrCharAt(v8::internal::Handle<v8::internal::Object>, unsigned int)',
type:'CPP',
nameUpdated_:false,
source: undefined,
}
]);
assertEquals(staticEntries[2],
[256,{size:1,
name:'v8::internal::Runtime_StringReplaceRegExpWithString(v8::internal::Arguments)',
type:'CPP',
nameUpdated_:false,
source: undefined,
}
]);
LinuxCppEntriesProvider.prototype.loadSymbols = oldLoadSymbols;
})();

131
deps/v8/test/mjsunit/tools/foozzie.js vendored Normal file
View File

@ -0,0 +1,131 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --correctness-fuzzer-suppressions
// Files: tools/clusterfuzz/foozzie/v8_mock.js
// Test foozzie mocks for differential fuzzing.
// Deterministic Math.random.
assertEquals(0.7098480789645691, Math.random());
assertEquals(0.9742682568175951, Math.random());
assertEquals(0.20008059867222983, Math.random());
// Deterministic date.
assertEquals(1477662728698, Date.now());
assertEquals(1477662728701, Date.now());
assertEquals(1477662728705, new Date().getTime());
assertEquals(710, new Date.prototype.constructor().getUTCMilliseconds());
// Deterministic arguments in constructor keep working.
assertEquals(819134640000,
new Date('December 17, 1995 03:24:00 GMT+1000').getTime());
// Deterministic DateTimeFormat.
if (this.Intl) {
const df = new Intl.DateTimeFormat(undefined, {fractionalSecondDigits: 3});
assertEquals('004', df.format());
assertEquals('004', df.formatToParts()[0].value);
}
// Dummy performance methods.
assertEquals(1.2, performance.now());
assertEquals(undefined, performance.mark("a mark"));
assertEquals(undefined, performance.measure("a measure"));
assertEquals([], performance.measureMemory());
// Worker messages follow a predefined deterministic pattern.
const worker = new Worker(``, {type: 'string'});
assertEquals(0, worker.getMessage());
assertEquals(-1, worker.getMessage());
// NaN patterns in typed arrays are mocked out. Test that we get no
// difference between unoptimized and optimized code.
function testSameOptimized(pattern, create_fun) {
const expected = new Uint32Array(pattern);
%PrepareFunctionForOptimization(create_fun);
assertEquals(expected, create_fun());
%OptimizeFunctionOnNextCall(create_fun);
assertEquals(expected, create_fun());
}
function testArrayType(arrayType, pattern) {
// Test passing NaNs to constructor with array.
let create = function() {
return new Uint32Array(new arrayType([-NaN]).buffer);
};
testSameOptimized(pattern, create);
// Test passing NaNs to constructor with iterator.
create = function() {
const iter = function*(){ yield* [-NaN]; }();
return new Uint32Array(new arrayType(iter).buffer);
};
testSameOptimized(pattern, create);
// Test setting NaN property.
create = function() {
const arr = new arrayType(1);
arr[0] = -NaN;
return new Uint32Array(arr.buffer);
};
testSameOptimized(pattern, create);
// Test passing NaN using set.
create = function() {
const arr = new arrayType(1);
arr.set([-NaN], 0);
return new Uint32Array(arr.buffer);
};
testSameOptimized(pattern, create);
}
var isBigEndian = new Uint8Array(new Uint16Array([0xABCD]).buffer)[0] === 0xAB;
testArrayType(Float32Array, [1065353216]);
if (isBigEndian){
testArrayType(Float64Array, [1072693248, 0]);
}
else {
testArrayType(Float64Array, [0, 1072693248]);
}
// Test that DataView has the same NaN patterns with optimized and
// unoptimized code.
var expected_array = [4213246272,405619796,61503,0,3675212096,32831];
if (isBigEndian){
expected_array = [1074340347,1413754136,1072693248,0,1078530011,1065353216];
}
testSameOptimized(expected_array, () => {
const array = new Uint32Array(6);
const view = new DataView(array.buffer);
view.setFloat64(0, Math.PI);
view.setFloat64(8, -undefined);
view.setFloat32(16, Math.fround(Math.PI));
view.setFloat32(20, -undefined);
assertEquals(Math.PI, view.getFloat64(0));
assertEquals(Math.fround(Math.PI), view.getFloat32(16));
return array;
});
// Realm.eval is just eval.
assertEquals(1477662728716, Realm.eval(Realm.create(), `Date.now()`));
// Test mocked Atomics.waitAsync.
let then_called = false;
Atomics.waitAsync().value.then(() => {then_called = true;});
assertEquals(true, then_called);
// Test .caller access is neutralized.
function callee() {
assertEquals(null, callee.caller);
}
function caller() {
callee();
}
caller();
// Neutralized APIs.
let object = {'foo': 42}
assertEquals(d8.serializer.serialize(object), object)
assertEquals(d8.serializer.deserialize(object), object)
assertEquals(d8.profiler.setOnProfileEndListener(object), object)
assertEquals(d8.profiler.triggerSample(object), object)
assertEquals(d8.log.getAndStop(object), object)

View File

@ -0,0 +1,14 @@
// Copyright 2024 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
// Files: tools/clusterfuzz/foozzie/v8_mock.js
// Files: tools/clusterfuzz/foozzie/v8_mock_archs.js
// Test foozzie architecture-specific mocks for differential fuzzing.
// Test suppressions for Math.pow precision differences.
assertEquals(61180.2063551, Math.pow(35, 3.1));
assertEquals(1.27173474826e+29, Math.pow(3, 61));
assertEquals(8.35351641266e-237, Math.pow(Math.E, -543.5899844621109));

View File

@ -0,0 +1,89 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
// Files: tools/clusterfuzz/foozzie/v8_mock.js
// Test foozzie typed-array-specific mocks for differential fuzzing.
// Max typed array length is mocked and restricted to 1MiB buffer.
const maxBytes = 1048576;
// The maximum also holds for array buffer and shared array buffer.
assertEquals(maxBytes, new ArrayBuffer(maxBytes + 1).byteLength);
assertEquals(maxBytes, new SharedArrayBuffer(maxBytes + 1).byteLength);
function testArrayType(type) {
const name = type.name;
const bytesPerElem = type.BYTES_PER_ELEMENT;
const maxElem = maxBytes / bytesPerElem;
function testLength(expectedLength, arr) {
const expectedBytes = expectedLength * bytesPerElem;
assertEquals(expectedBytes, arr.byteLength, name);
assertEquals(expectedLength, arr.length, name);
}
// Test length argument in constructor.
testLength(maxElem - 1, new type(maxElem - 1));
testLength(maxElem, new type(maxElem));
testLength(maxElem, new type(maxElem + 1));
// Test buffer argument in constructor.
// Unaligned offsets don't throw.
const buffer = new ArrayBuffer(maxBytes);
new type(buffer, 1);
new type(buffer, 3);
// Offsets work or are capped.
function bytes(elements) {
return elements * bytesPerElem;
}
testLength(maxElem, new type(buffer, 0));
testLength(maxElem - 1, new type(buffer, bytes(1)));
testLength(1, new type(buffer, bytes(maxElem - 1)));
testLength(0, new type(buffer, bytes(maxElem)));
testLength(0, new type(buffer, bytes(maxElem + 1)));
// Offset and length work or are capped.
testLength(1, new type(buffer, 0, 1));
testLength(1, new type(buffer, bytesPerElem, 1));
testLength(maxElem - 2, new type(buffer, bytes(1), maxElem - 2));
testLength(maxElem - 1, new type(buffer, bytes(1), maxElem - 1));
testLength(maxElem - 1, new type(buffer, bytes(1), maxElem));
testLength(0, new type(buffer, bytes(maxElem - 1), 0));
testLength(1, new type(buffer, bytes(maxElem - 1), 1));
testLength(1, new type(buffer, bytes(maxElem - 1), 2));
// Length works or is capped despite bogus offset.
testLength(1, new type(buffer, "bad", 1));
testLength(maxElem, new type(buffer, "bad", maxElem + 1));
testLength(1, new type(buffer, {"x": 4}, 1));
testLength(maxElem, new type(buffer, {"x": 4}, maxElem + 1));
// Insertion with "set" works or is capped.
let set0 = 0;
let set1 = 1;
if (name.startsWith("Big")) {
set0 = 0n;
set1 = 1n;
}
arr = new type(4);
arr.set([set1], 1);
assertEquals(new type([set0, set1, set0, set0]), arr, name);
arr.set([set1, set1], 3); // Capped to 2.
assertEquals(new type([set0, set1, set1, set1]), arr, name);
}
testArrayType(Int8Array);
testArrayType(Uint8Array);
testArrayType(Uint8ClampedArray);
testArrayType(Int16Array);
testArrayType(Uint16Array);
testArrayType(Int32Array);
testArrayType(Uint32Array);
testArrayType(BigInt64Array);
testArrayType(BigUint64Array);
testArrayType(Float32Array);
testArrayType(Float64Array);

View File

@ -0,0 +1,18 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
// Files: tools/clusterfuzz/foozzie/v8_mock.js
// Files: tools/clusterfuzz/foozzie/v8_mock_webassembly.js
// Test foozzie webassembly-specfific mocks for differential fuzzing.
// No reference errors when accessing WebAssembly.
WebAssembly[0];
WebAssembly[" "];
WebAssembly.foo;
WebAssembly.foo();
WebAssembly.foo().bar;
WebAssembly.foo().bar();
WebAssembly.foo().bar[0];

61
deps/v8/test/mjsunit/tools/log-ic.js vendored Normal file
View File

@ -0,0 +1,61 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --log-ic --logfile='+' --allow-natives-syntax
// The idea behind this test is to make sure we do not crash when using the
// --log-ic flag.
(function testLoadIC() {
function loadIC(obj) {
return obj.field;
}
%EnsureFeedbackVectorForFunction(loadIC);
var obj = {field: 'hello'};
loadIC(obj);
loadIC(obj);
loadIC(obj);
})();
(function testStoreIC() {
function storeIC(obj, value) {
return obj.field = value;
}
%EnsureFeedbackVectorForFunction(storeIC);
var obj = {field: 'hello'};
storeIC(obj, 'world');
storeIC(obj, 'world');
storeIC(obj, 'world');
})();
(function testKeyedLoadIC() {
function keyedLoadIC(obj, field) {
return obj[field];
}
%EnsureFeedbackVectorForFunction(keyedLoadIC);
var obj = {field: 'hello'};
keyedLoadIC(obj, 'field');
keyedLoadIC(obj, 'field');
keyedLoadIC(obj, 'field');
})();
(function testKeyedStoreIC() {
function keyedStoreIC(obj, field, value) {
return obj[field] = value;
}
%EnsureFeedbackVectorForFunction(keyedStoreIC);
var obj = {field: 'hello'};
keyedStoreIC(obj, 'field', 'world');
keyedStoreIC(obj, 'field', 'world');
keyedStoreIC(obj, 'field', 'world');
})();

25
deps/v8/test/mjsunit/tools/log.js vendored Normal file
View File

@ -0,0 +1,25 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --logfile='+' --log --log-code
function testFunctionWithFunnyName(o) {
return o.a;
}
(function testLoopWithFunnyName() {
const o = {a:1};
let result = 0;
for (let i = 0; i < 1000; i++) {
result += testFunctionWithFunnyName(o);
}
})();
const log = d8.log.getAndStop();
// Check that we have a minimally working log file.
assertTrue(log.length > 0);
assertTrue(log.indexOf('v8-version') == 0);
assertTrue(log.indexOf('testFunctionWithFunnyName') >= 10);
assertTrue(log.indexOf('testLoopWithFunnyName') >= 10);

View File

@ -0,0 +1,37 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --logfile='+' --log --log-code --log-function-events
// Flags: --no-stress-background-compile
let twoByteName = "twoByteName_🍕"
let o = {
[twoByteName](obj) {
return obj.a
}
}
function testFunctionWithFunnyName(o) {
return o.a;
}
(function testLoopWithFunnyName() {
let object = {a:1};
let result = 0;
for (let i = 0; i < 1000; i++) {
result += o[twoByteName](object);
}
})();
var __v_3 = {};
({})['foobar\u2653'] = null;
eval('__v_3 = function foobar() { return foobar };');
__v_3();
const log = d8.log.getAndStop();
// Check that we have a minimally working log file.
assertTrue(log.length > 0);
assertTrue(log.indexOf('v8-version') == 0);
assertTrue(log.indexOf('testFunctionWithFunnyName') >= 10);
assertTrue(log.indexOf("twoByteName") >= 10);
assertTrue(log.indexOf('testLoopWithFunnyName') >= 10);

View File

@ -0,0 +1,59 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --logfile='+' --log --log-maps --log-ic --log-code
// Flags: --log-function-events --no-predictable
import { Processor } from "../../../tools/system-analyzer/processor.mjs";
// log code start
function doWork() {
let array = [];
for (let i = 0; i < 500; i++) {
doWorkStep(i, array);
}
let sum = 0;
for (let i = 0; i < 500; i++) {
sum += array[i]["property" + i];
}
return sum;
}
function doWorkStep(i, array) {
const obj = {
["property" + i]: i,
};
array.push(obj);
obj.custom1 = 1;
obj.custom2 = 2;
}
const result = doWork();
// log code end
const logString = d8.log.getAndStop();
assertTrue(logString.length > 0);
const useBigIntAddresses = true;
const processor = new Processor(useBigIntAddresses);
await processor.processChunk(logString);
await processor.finalize();
const maps = processor.mapTimeline;
const ics = processor.icTimeline;
const scripts = processor.scripts;
(function testResults() {
assertEquals(result, 124750);
assertTrue(maps.length > 0);
assertTrue(ics.length > 0);
assertTrue(scripts.length > 0);
})();
(function testIcKeys() {
const keys = new Set();
ics.forEach(ic => keys.add(ic.key));
assertTrue(keys.has("custom1"));
assertTrue(keys.has("custom2"));
assertTrue(keys.has("push"));
})();

View File

@ -0,0 +1,58 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --logfile='+' --log --log-maps --log-ic --log-code
// Flags: --log-function-events --no-predictable
import { Processor } from "../../../tools/system-analyzer/processor.mjs";
// log code start
function doWork() {
let array = [];
for (let i = 0; i < 500; i++) {
doWorkStep(i, array);
}
let sum = 0;
for (let i = 0; i < 500; i++) {
sum += array[i]["property" + i];
}
return sum;
}
function doWorkStep(i, array) {
const obj = {
["property" + i]: i,
};
array.push(obj);
obj.custom1 = 1;
obj.custom2 = 2;
}
const result = doWork();
// log code end
const logString = d8.log.getAndStop();
assertTrue(logString.length > 0);
const processor = new Processor();
await processor.processChunk(logString);
await processor.finalize();
const maps = processor.mapTimeline;
const ics = processor.icTimeline;
const scripts = processor.scripts;
(function testResults() {
assertEquals(result, 124750);
assertTrue(maps.length > 0);
assertTrue(ics.length > 0);
assertTrue(scripts.length > 0);
})();
(function testIcKeys() {
const keys = new Set();
ics.forEach(ic => keys.add(ic.key));
assertTrue(keys.has("custom1"));
assertTrue(keys.has("custom2"));
assertTrue(keys.has("push"));
})();

345
deps/v8/test/mjsunit/tools/profile.mjs vendored Normal file
View File

@ -0,0 +1,345 @@
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import { Profile } from "../../../tools/profile.mjs";
function stackToString(stack) {
return stack.join(' -> ');
};
function assertPathExists(root, path, opt_message) {
var message = opt_message ? ' (' + opt_message + ')' : '';
assertNotNull(root.descendToChild(path, function(node, pos) {
assertNotNull(node,
stackToString(path.slice(0, pos)) + ' has no child ' +
path[pos] + message);
}), opt_message);
};
function assertNoPathExists(root, path, opt_message) {
var message = opt_message ? ' (' + opt_message + ')' : '';
assertNull(root.descendToChild(path), opt_message);
};
function countNodes(profile, traverseFunc) {
var count = 0;
traverseFunc.call(profile, function () { count++; });
return count;
};
function ProfileTestDriver() {
this.profile = new Profile();
this.stack_ = [];
this.addFunctions_();
};
// Addresses inside functions.
ProfileTestDriver.prototype.funcAddrs_ = {
'lib1-f1': 0x11110, 'lib1-f2': 0x11210,
'lib2-f1': 0x21110, 'lib2-f2': 0x21210,
'T: F1': 0x50110, 'T: F2': 0x50210, 'T: F3': 0x50410 };
ProfileTestDriver.prototype.addFunctions_ = function() {
this.profile.addLibrary('lib1', 0x11000, 0x12000);
this.profile.addStaticCode('lib1-f1', 0x11100, 0x11900);
this.profile.addStaticCode('lib1-f2', 0x11200, 0x11500);
this.profile.addLibrary('lib2', 0x21000, 0x22000);
this.profile.addStaticCode('lib2-f1', 0x21100, 0x21900);
this.profile.addStaticCode('lib2-f2', 0x21200, 0x21500);
this.profile.addCode('T', 'F1', 1, 0x50100, 0x100);
this.profile.addCode('T', 'F2', 2, 0x50200, 0x100);
this.profile.addCode('T', 'F3', 3, 0x50400, 0x100);
};
ProfileTestDriver.prototype.enter = function(funcName) {
// Stack looks like this: [pc, caller, ..., main].
// Therefore, we are adding entries at the beginning.
this.stack_.unshift(this.funcAddrs_[funcName]);
this.profile.recordTick(0, 0, this.stack_);
};
ProfileTestDriver.prototype.stay = function() {
this.profile.recordTick(0, 0, this.stack_);
};
ProfileTestDriver.prototype.leave = function() {
this.stack_.shift();
};
ProfileTestDriver.prototype.execute = function() {
this.enter('lib1-f1');
this.enter('lib1-f2');
this.enter('T: F1');
this.enter('T: F2');
this.leave();
this.stay();
this.enter('lib2-f1');
this.enter('lib2-f1');
this.leave();
this.stay();
this.leave();
this.enter('T: F3');
this.enter('T: F3');
this.enter('T: F3');
this.leave();
this.enter('T: F2');
this.stay();
this.leave();
this.leave();
this.leave();
this.leave();
this.enter('lib2-f1');
this.enter('lib1-f1');
this.leave();
this.leave();
this.stay();
this.leave();
};
function Inherits(childCtor, parentCtor) {
function tempCtor() {};
tempCtor.prototype = parentCtor.prototype;
childCtor.superClass_ = parentCtor.prototype;
childCtor.prototype = new tempCtor();
childCtor.prototype.constructor = childCtor;
};
(function testCallTreeBuilding() {
function Driver() {
ProfileTestDriver.call(this);
this.namesTopDown = [];
this.namesBottomUp = [];
};
Inherits(Driver, ProfileTestDriver);
Driver.prototype.enter = function(func) {
this.namesTopDown.push(func);
this.namesBottomUp.unshift(func);
assertNoPathExists(this.profile.getTopDownProfile().getRoot(), this.namesTopDown,
'pre enter/topDown');
assertNoPathExists(this.profile.getBottomUpProfile().getRoot(), this.namesBottomUp,
'pre enter/bottomUp');
Driver.superClass_.enter.call(this, func);
assertPathExists(this.profile.getTopDownProfile().getRoot(), this.namesTopDown,
'post enter/topDown');
assertPathExists(this.profile.getBottomUpProfile().getRoot(), this.namesBottomUp,
'post enter/bottomUp');
};
Driver.prototype.stay = function() {
var preTopDownNodes = countNodes(this.profile, this.profile.traverseTopDownTree);
var preBottomUpNodes = countNodes(this.profile, this.profile.traverseBottomUpTree);
Driver.superClass_.stay.call(this);
var postTopDownNodes = countNodes(this.profile, this.profile.traverseTopDownTree);
var postBottomUpNodes = countNodes(this.profile, this.profile.traverseBottomUpTree);
// Must be no changes in tree layout.
assertEquals(preTopDownNodes, postTopDownNodes, 'stay/topDown');
assertEquals(preBottomUpNodes, postBottomUpNodes, 'stay/bottomUp');
};
Driver.prototype.leave = function() {
Driver.superClass_.leave.call(this);
this.namesTopDown.pop();
this.namesBottomUp.shift();
};
var testDriver = new Driver();
testDriver.execute();
})();
function assertNodeWeights(root, path, selfTicks, totalTicks) {
var node = root.descendToChild(path);
var stack = stackToString(path);
assertNotNull(node, 'node not found: ' + stack);
assertEquals(selfTicks, node.selfWeight, 'self of ' + stack);
assertEquals(totalTicks, node.totalWeight, 'total of ' + stack);
};
(function testTopDownRootProfileTicks() {
var testDriver = new ProfileTestDriver();
testDriver.execute();
var pathWeights = [
[['lib1-f1'], 1, 16],
[['lib1-f1', 'lib1-f2'], 2, 15],
[['lib1-f1', 'lib1-f2', 'T: F1'], 2, 11],
[['lib1-f1', 'lib1-f2', 'T: F1', 'T: F2'], 1, 1],
[['lib1-f1', 'lib1-f2', 'T: F1', 'lib2-f1'], 2, 3],
[['lib1-f1', 'lib1-f2', 'T: F1', 'lib2-f1', 'lib2-f1'], 1, 1],
[['lib1-f1', 'lib1-f2', 'T: F1', 'T: F3'], 1, 5],
[['lib1-f1', 'lib1-f2', 'T: F1', 'T: F3', 'T: F3'], 1, 4],
[['lib1-f1', 'lib1-f2', 'T: F1', 'T: F3', 'T: F3', 'T: F3'], 1, 1],
[['lib1-f1', 'lib1-f2', 'T: F1', 'T: F3', 'T: F3', 'T: F2'], 2, 2],
[['lib1-f1', 'lib1-f2', 'lib2-f1'], 1, 2],
[['lib1-f1', 'lib1-f2', 'lib2-f1', 'lib1-f1'], 1, 1]
];
var root = testDriver.profile.getTopDownProfile().getRoot();
for (var i = 0; i < pathWeights.length; ++i) {
var data = pathWeights[i];
assertNodeWeights(root, data[0], data[1], data[2]);
}
})();
(function testRootFlatProfileTicks() {
function Driver() {
ProfileTestDriver.call(this);
this.namesTopDown = [''];
this.counters = {};
this.root = null;
};
Inherits(Driver, ProfileTestDriver);
Driver.prototype.increment = function(func, self, total) {
if (!(func in this.counters)) {
this.counters[func] = { self: 0, total: 0 };
}
this.counters[func].self += self;
this.counters[func].total += total;
};
Driver.prototype.incrementTotals = function() {
// Only count each function in the stack once.
var met = {};
for (var i = 0; i < this.namesTopDown.length; ++i) {
var name = this.namesTopDown[i];
if (!(name in met)) {
this.increment(name, 0, 1);
}
met[name] = true;
}
};
Driver.prototype.enter = function(func) {
Driver.superClass_.enter.call(this, func);
this.namesTopDown.push(func);
this.increment(func, 1, 0);
this.incrementTotals();
};
Driver.prototype.stay = function() {
Driver.superClass_.stay.call(this);
this.increment(this.namesTopDown[this.namesTopDown.length - 1], 1, 0);
this.incrementTotals();
};
Driver.prototype.leave = function() {
Driver.superClass_.leave.call(this);
this.namesTopDown.pop();
};
Driver.prototype.extractRoot = function() {
assertTrue('' in this.counters);
this.root = this.counters[''];
delete this.counters[''];
};
var testDriver = new Driver();
testDriver.execute();
testDriver.extractRoot();
var counted = 0;
for (var c in testDriver.counters) {
counted++;
}
var flatProfileRoot = testDriver.profile.getFlatProfile().getRoot();
assertEquals(testDriver.root.self, flatProfileRoot.selfWeight);
assertEquals(testDriver.root.total, flatProfileRoot.totalWeight);
var flatProfile = flatProfileRoot.exportChildren();
assertEquals(counted, flatProfile.length, 'counted vs. flatProfile');
for (var i = 0; i < flatProfile.length; ++i) {
var rec = flatProfile[i];
assertTrue(rec.label in testDriver.counters, 'uncounted: ' + rec.label);
var reference = testDriver.counters[rec.label];
assertEquals(reference.self, rec.selfWeight, 'self of ' + rec.label);
assertEquals(reference.total, rec.totalWeight, 'total of ' + rec.label);
}
})();
(function testFunctionCalleesProfileTicks() {
var testDriver = new ProfileTestDriver();
testDriver.execute();
var pathWeights = [
[['lib2-f1'], 3, 5],
[['lib2-f1', 'lib2-f1'], 1, 1],
[['lib2-f1', 'lib1-f1'], 1, 1]
];
var profile = testDriver.profile.getTopDownProfile('lib2-f1');
var root = profile.getRoot();
for (var i = 0; i < pathWeights.length; ++i) {
var data = pathWeights[i];
assertNodeWeights(root, data[0], data[1], data[2]);
}
})();
(function testFunctionFlatProfileTicks() {
var testDriver = new ProfileTestDriver();
testDriver.execute();
var flatWeights = {
'lib2-f1': [1, 1],
'lib1-f1': [1, 1]
};
var flatProfileRoot =
testDriver.profile.getFlatProfile('lib2-f1').findOrAddChild('lib2-f1');
assertEquals(3, flatProfileRoot.selfWeight);
assertEquals(5, flatProfileRoot.totalWeight);
var flatProfile = flatProfileRoot.exportChildren();
assertEquals(2, flatProfile.length, 'counted vs. flatProfile');
for (var i = 0; i < flatProfile.length; ++i) {
var rec = flatProfile[i];
assertTrue(rec.label in flatWeights, 'uncounted: ' + rec.label);
var reference = flatWeights[rec.label];
assertEquals(reference[0], rec.selfWeight, 'self of ' + rec.label);
assertEquals(reference[1], rec.totalWeight, 'total of ' + rec.label);
}
})();

View File

@ -0,0 +1,94 @@
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import { ProfileView } from "../../../tools/profile_view.mjs";
function createNode(name, time, opt_parent) {
var node = new ProfileView.Node(name, time, time, null);
if (opt_parent) {
opt_parent.addChild(node);
}
return node;
}
(function testSorting() {
//
// Build a tree:
// root +--c/5
// | |
// +--a/2 +--b/3--+--d/4
// | | |
// +--a/1--+--c/1 +--d/2
// | |
// +--c/1 +--b/2
//
// So we can sort it using 2 fields: name and time.
var root = createNode('root', 0);
createNode('a', 2, root);
var a1 = createNode('a', 1, root);
createNode('c', 1, root);
var b3 = createNode('b', 3, a1);
createNode('c', 1, a1);
createNode('b', 2, a1);
createNode('c', 5, b3);
createNode('d', 4, b3);
createNode('d', 2, b3);
var view = new ProfileView(root);
var flatTree = [];
function fillFlatTree(node) {
flatTree.push(node.internalFuncName);
flatTree.push(node.selfTime);
}
view.traverse(fillFlatTree);
assertEquals(
['root', 0,
'a', 2, 'a', 1, 'c', 1,
'b', 3, 'c', 1, 'b', 2,
'c', 5, 'd', 4, 'd', 2], flatTree);
function cmpStrs(s1, s2) {
return s1 == s2 ? 0 : (s1 < s2 ? -1 : 1);
}
view.sort(function(n1, n2) {
return cmpStrs(n1.internalFuncName, n2.internalFuncName) ||
(n1.selfTime - n2.selfTime);
});
flatTree = [];
view.traverse(fillFlatTree);
assertEquals(
['root', 0,
'a', 1, 'a', 2, 'c', 1,
'b', 2, 'b', 3, 'c', 1,
'c', 5, 'd', 2, 'd', 4], flatTree);
})();

165
deps/v8/test/mjsunit/tools/splaytree.mjs vendored Normal file
View File

@ -0,0 +1,165 @@
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import { SplayTree } from "../../../tools/splaytree.mjs";
(function testIsEmpty() {
var tree = new SplayTree();
assertTrue(tree.isEmpty());
tree.insert(0, 'value');
assertFalse(tree.isEmpty());
})();
(function testExportValues() {
var tree = new SplayTree();
assertArrayEquals([], tree.exportValues());
tree.insert(0, 'value');
assertArrayEquals(['value'], tree.exportValues());
tree.insert(0, 'value');
assertArrayEquals(['value'], tree.exportValues());
})();
function createSampleTree() {
// Creates the following tree:
// 50
// / \
// 30 60
// / \ \
// 10 40 90
// \ / \
// 20 70 100
// / \
// 15 80
//
// We can't use the 'insert' method because it also uses 'splay_'.
return { key: 50, value: 50,
left: { key: 30, value: 30,
left: { key: 10, value: 10, left: null,
right: { key: 20, value: 20,
left: { key: 15, value: 15,
left: null, right: null },
right: null } },
right: { key: 40, value: 40, left: null, right: null } },
right: { key: 60, value: 60, left: null,
right: { key: 90, value: 90,
left: { key: 70, value: 70, left: null,
right: { key: 80, value: 80,
left: null, right: null } },
right: { key: 100, value: 100,
left: null, right: null } } } };
};
(function testSplay() {
var tree = new SplayTree();
tree.root_ = createSampleTree();
assertArrayEquals([50, 30, 60, 10, 40, 90, 20, 70, 100, 15, 80],
tree.exportValues());
tree.splay_(50);
assertArrayEquals([50, 30, 60, 10, 40, 90, 20, 70, 100, 15, 80],
tree.exportValues());
tree.splay_(80);
assertArrayEquals([80, 60, 90, 50, 70, 100, 30, 10, 40, 20, 15],
tree.exportValues());
})();
(function testInsert() {
var tree = new SplayTree();
tree.insert(5, 'root');
tree.insert(3, 'left');
assertArrayEquals(['left', 'root'], tree.exportValues());
tree.insert(7, 'right');
assertArrayEquals(['right', 'root', 'left'], tree.exportValues());
})();
(function testFind() {
var tree = new SplayTree();
tree.insert(5, 'root');
tree.insert(3, 'left');
tree.insert(7, 'right');
assertEquals('root', tree.find(5).value);
assertEquals('left', tree.find(3).value);
assertEquals('right', tree.find(7).value);
assertEquals(null, tree.find(0));
assertEquals(null, tree.find(100));
assertEquals(null, tree.find(-100));
})();
(function testFindMin() {
var tree = new SplayTree();
assertEquals(null, tree.findMin());
tree.insert(5, 'root');
tree.insert(3, 'left');
tree.insert(7, 'right');
assertEquals('left', tree.findMin().value);
})();
(function testFindMax() {
var tree = new SplayTree();
assertEquals(null, tree.findMax());
tree.insert(5, 'root');
tree.insert(3, 'left');
tree.insert(7, 'right');
assertEquals('right', tree.findMax().value);
})();
(function testFindGreatestLessThan() {
var tree = new SplayTree();
assertEquals(null, tree.findGreatestLessThan(10));
tree.insert(5, 'root');
tree.insert(3, 'left');
tree.insert(7, 'right');
assertEquals('right', tree.findGreatestLessThan(10).value);
assertEquals('right', tree.findGreatestLessThan(7).value);
assertEquals('root', tree.findGreatestLessThan(6).value);
assertEquals('left', tree.findGreatestLessThan(4).value);
assertEquals(null, tree.findGreatestLessThan(2));
})();
(function testRemove() {
var tree = new SplayTree();
assertThrows('tree.remove(5)');
tree.insert(5, 'root');
tree.insert(3, 'left');
tree.insert(7, 'right');
assertThrows('tree.remove(1)');
assertThrows('tree.remove(6)');
assertThrows('tree.remove(10)');
assertEquals('root', tree.remove(5).value);
assertEquals('left', tree.remove(3).value);
assertEquals('right', tree.remove(7).value);
assertArrayEquals([], tree.exportValues());
})();

View File

@ -0,0 +1,11 @@
shared-library,shell,0x08048000,0x081ee000,0
shared-library,/lib32/libm-2.7.so,0xf7db6000,0xf7dd9000,0
shared-library,ffffe000-fffff000,0xffffe000,0xfffff000,0
profiler,begin,1
code-creation,Stub,0,100,0x424260,348,CompareStub_GE
code-creation,LazyCompile,0,101,0x2a8100,18535,DrawQube 3d-cube.js:188,0xf43abcac,
code-creation,LazyCompile,0,102,0x480100,3908,DrawLine 3d-cube.js:17,0xf43abc50,
tick,0x424284,0,0,0x480600,0,0x2aaaa5
tick,0x42429f,0,0,0x480600,0,0x2aacb4
tick,0x48063d,0,0,0x2d0f7c,0,0x2aaec6
profiler,end

View File

@ -0,0 +1,7 @@
[
["exp",4158389888,4158390051],
["fegetexcept",4158374368,4158374389],
["v8::internal::Runtime_Math_exp(v8::internal::Arguments)",135412512,135412608],
["v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)",135235584,135237008],
["v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)",135234064,135235584]
]

View File

@ -0,0 +1,74 @@
Statistical profiling result from v8.log, (303 ticks, 0 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
24 7.9% /usr/local/google/home/cbruni/Documents/v8/v8/out/x64.release/d8
10 3.3% /usr/lib/x86_64-linux-gnu/libc-2.31.so
4 1.3% /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
[JavaScript]:
ticks total nonlib name
102 33.7% 38.5% LazyCompile: *<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
25 8.3% 9.4% LazyCompile: *ics test/mjsunit/tools/tickprocessor-test.js:47:13
21 6.9% 7.9% LazyCompile: *loop test/mjsunit/tools/tickprocessor-test.js:10:14
[C++]:
ticks total nonlib name
99 32.7% 37.4% v8_Default_embedded_blob_code_data_
12 4.0% 4.5% __write
3 1.0% 1.1% fwrite
2 0.7% 0.8% v8::internal::RootScavengeVisitor::VisitRootPointer(v8::internal::Root, char const*, v8::internal::FullObjectSlot)
1 0.3% 0.4% v8::internal::compiler::TopLevelLiveRange::AddUseInterval(v8::internal::compiler::LifetimePosition, v8::internal::compiler::LifetimePosition, v8::internal::Zone*, bool)
[Summary]:
ticks total nonlib name
148 48.8% 55.8% JavaScript
117 38.6% 44.2% C++
20 6.6% 7.5% GC
38 12.5% Shared libraries
[C++ entry points]:
ticks cpp total name
93 93.9% 30.7% v8_Default_embedded_blob_code_data_
4 4.0% 1.3% v8::internal::Runtime_CompileForOnStackReplacement(int, unsigned long*, v8::internal::Isolate*)
2 2.0% 0.7% v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*)
[Bottom up (heavy) profile]:
Note: percentage shows a share of a particular caller in the total
amount of its parent calls.
Callers occupying less than 1.0% are not shown.
ticks parent name
102 33.7% LazyCompile: *<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
99 32.7% v8_Default_embedded_blob_code_data_
76 76.8% LazyCompile: *<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
16 16.2% LazyCompile: *ics test/mjsunit/tools/tickprocessor-test.js:47:13
16 100.0% Script: ~<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
1 1.0% Script: ~<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
25 8.3% LazyCompile: *ics test/mjsunit/tools/tickprocessor-test.js:47:13
25 100.0% Script: ~<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
24 7.9% /usr/local/google/home/cbruni/Documents/v8/v8/out/x64.release/d8
4 16.7% LazyCompile: ~ics test/mjsunit/tools/tickprocessor-test.js:47:13
4 100.0% Script: ~<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
3 12.5% v8::internal::Runtime_CompileForOnStackReplacement(int, unsigned long*, v8::internal::Isolate*)
2 66.7% Script: ~<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
1 33.3% LazyCompile: ~loop test/mjsunit/tools/tickprocessor-test.js:10:14
1 100.0% Script: ~<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
2 8.3% v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*)
2 100.0% LazyCompile: *<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
2 8.3% Script: ~<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
2 8.3% LazyCompile: ~read_megamorphic test/mjsunit/tools/tickprocessor-test.js:35:26
2 100.0% LazyCompile: ~ics test/mjsunit/tools/tickprocessor-test.js:47:13
2 100.0% Script: ~<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
21 6.9% LazyCompile: *loop test/mjsunit/tools/tickprocessor-test.js:10:14
21 100.0% Script: ~<anonymous> test/mjsunit/tools/tickprocessor-test.js:1:1
12 4.0% __write
10 3.3% /usr/lib/x86_64-linux-gnu/libc-2.31.so
4 1.3% /usr/lib/x86_64-linux-gnu/libpthread-2.31.so

View File

@ -0,0 +1,58 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Sample file for creating tickprocessor-test.log
"use strict"
let result;
function loop() {
let result = 0;
for (let i = 0; i < 10_000_000; i++) {
result = add(result, 1);
}
return result;
}
function add(a, b) {
return a + b;
}
result = loop();
result = loop();
// Cause some IC misses
function read_monomorphic(o) {
return o.value
}
function read_polymorphic(o) {
return o.value
}
function read_megamorphic(o) {
return o.value
}
const objects = [];
for (let i = 0; i < 100; i++) {
const object = {};
object['key' + i ];
object['value'] = 1 + i/100;
objects.push(object)
}
function ics() {
result = 0;
for (let i = 0; i < objects.length; i++) {
result += read_monomorphic(objects[0]);
result += read_polymorphic(objects[i % 3])
result += read_megamorphic(objects[i]);
}
}
for (let i = 0; i < 10_000; i++) {
ics();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
[
[
"v8_Default_embedded_blob_code_data_",
93957345371712,
93957345373344
],
[
"v8::internal::Runtime_CompileForOnStackReplacement(int, unsigned long*, v8::internal::Isolate*)",
93957340005712,
93957340007781
],
[
"__write",
139871564238624,
139871564238781
],
[
"fwrite",
139871563740416,
139871563740870
],
[
"v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*)",
93957340107136,
93957340107454
],
[
"v8::internal::compiler::TopLevelLiveRange::AddUseInterval(v8::internal::compiler::LifetimePosition, v8::internal::compiler::LifetimePosition, v8::internal::Zone*, bool)",
93957343090272,
93957343090533
],
[
"v8::internal::RootScavengeVisitor::VisitRootPointer(v8::internal::Root, char const*, v8::internal::FullObjectSlot)",
93957337529568,
93957337529610
]
]

View File

@ -0,0 +1,62 @@
Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
3 23.1% /lib32/libm-2.7.so
1 7.7% ffffe000-fffff000
[JavaScript]:
ticks total nonlib name
[C++]:
ticks total nonlib name
2 15.4% 22.2% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
1 7.7% 11.1% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 7.7% 11.1% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 7.7% 11.1% exp
[Summary]:
ticks total nonlib name
0 0.0% 0.0% JavaScript
5 38.5% 55.6% C++
0 0.0% 0.0% GC
4 30.8% Shared libraries
2 15.4% Unaccounted
[C++ entry points]:
ticks cpp total name
2 40.0% 15.4% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
1 20.0% 7.7% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 20.0% 7.7% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 20.0% 7.7% exp
[Bottom up (heavy) profile]:
Note: percentage shows a share of a particular caller in the total
amount of its parent calls.
Callers occupying less than 1.0% are not shown.
ticks parent name
3 23.1% /lib32/libm-2.7.so
3 100.0% LazyCompile: exp native math.js:41
3 100.0% Script: exp.js
2 15.4% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
2 100.0% LazyCompile: exp native math.js:41
2 100.0% Script: exp.js
2 15.4% UNKNOWN
1 50.0% LazyCompile: exp native math.js:41
1 100.0% Script: exp.js
1 7.7% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 100.0% Script: exp.js
1 7.7% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 100.0% Script: exp.js
1 7.7% ffffe000-fffff000
1 7.7% exp
1 100.0% LazyCompile: exp native math.js:41
1 100.0% Script: exp.js

View File

@ -0,0 +1,35 @@
Statistical profiling result from v8.log, (3 ticks, 0 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
[JavaScript]:
ticks total nonlib name
2 66.7% 66.7% Stub: CompareStub_GE
1 33.3% 33.3% LazyCompile: DrawLine 3d-cube.js:17
[C++]:
ticks total nonlib name
[Summary]:
ticks total nonlib name
3 100.0% 100.0% JavaScript
0 0.0% 0.0% C++
0 0.0% 0.0% GC
0 0.0% Shared libraries
[C++ entry points]:
ticks cpp total name
[Bottom up (heavy) profile]:
Note: percentage shows a share of a particular caller in the total
amount of its parent calls.
Callers occupying less than 1.0% are not shown.
ticks parent name
2 66.7% Stub: CompareStub_GE
2 100.0% LazyCompile: DrawLine 3d-cube.js:17
2 100.0% LazyCompile: DrawQube 3d-cube.js:188
1 33.3% LazyCompile: DrawLine 3d-cube.js:17
1 100.0% LazyCompile: DrawQube 3d-cube.js:188

View File

@ -0,0 +1,27 @@
Statistical profiling result from v8.log, (13 ticks, 0 unaccounted, 13 excluded).
[Shared libraries]:
ticks total nonlib name
[JavaScript]:
ticks total nonlib name
[C++]:
ticks total nonlib name
[Summary]:
ticks total nonlib name
0 0.0% 0.0% JavaScript
0 0.0% 0.0% C++
0 0.0% 0.0% GC
0 0.0% Shared libraries
[C++ entry points]:
ticks cpp total name
[Bottom up (heavy) profile]:
Note: percentage shows a share of a particular caller in the total
amount of its parent calls.
Callers occupying less than 1.0% are not shown.
ticks parent name

View File

@ -0,0 +1,61 @@
Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
3 27.3% /lib32/libm-2.7.so
1 9.1% ffffe000-fffff000
[JavaScript]:
ticks total nonlib name
[C++]:
ticks total nonlib name
2 18.2% 28.6% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
1 9.1% 14.3% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 9.1% 14.3% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 9.1% 14.3% exp
[Summary]:
ticks total nonlib name
0 0.0% 0.0% JavaScript
5 45.5% 71.4% C++
0 0.0% 0.0% GC
4 36.4% Shared libraries
[C++ entry points]:
ticks cpp total name
2 40.0% 18.2% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
1 20.0% 9.1% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 20.0% 9.1% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 20.0% 9.1% exp
[Bottom up (heavy) profile]:
Note: percentage shows a share of a particular caller in the total
amount of its parent calls.
Callers occupying less than 1.0% are not shown.
ticks parent name
3 27.3% /lib32/libm-2.7.so
3 100.0% LazyCompile: exp native math.js:41
3 100.0% Script: exp.js
2 18.2% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
2 100.0% LazyCompile: exp native math.js:41
2 100.0% Script: exp.js
2 18.2% UNKNOWN
1 50.0% LazyCompile: exp native math.js:41
1 100.0% Script: exp.js
1 9.1% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 100.0% Script: exp.js
1 9.1% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 100.0% Script: exp.js
1 9.1% ffffe000-fffff000
1 9.1% exp
1 100.0% LazyCompile: exp native math.js:41
1 100.0% Script: exp.js

View File

@ -0,0 +1,25 @@
shared-library,shell,0x08048000,0x081ee000,0
shared-library,/lib32/libm-2.7.so,0xf7db6000,0xf7dd9000,0
shared-library,ffffe000-fffff000,0xffffe000,0xfffff000,0
profiler,begin,1
code-creation,Stub,0,100,0xf540a100,474,CEntryStub
code-creation,Script,0,101,0xf541cd80,736,exp.js
code-creation,Stub,0,102,0xf541d0e0,47,RuntimeStub_Math_exp
code-creation,LazyCompile,0,103,0xf541d120,145,exp native math.js:41
function-creation,0xf441d280,0xf541d120
code-creation,LoadIC,0,104,0xf541d280,117,j
code-creation,LoadIC,0,105,0xf541d360,63,i
tick,0x80f82d1,0,0,0,0,0xf541ce5c
tick,0x80f89a1,0,0,0,0,0xf541ce5c
tick,0x8123b5c,0,0,0,0,0xf541d1a1,0xf541ceea
tick,0x8123b65,0,0,0,0,0xf541d1a1,0xf541ceea
tick,0xf541d2be,0,0,0,0
tick,0xf541d320,0,0,0,0
tick,0xf541d384,0,0,0,0
tick,0xf7db94da,0,0,0,0,0xf541d1a1,0xf541ceea
tick,0xf7db951c,0,0,0,0,0xf541d1a1,0xf541ceea
tick,0xf7dbc508,0,0,0,0,0xf541d1a1,0xf541ceea
tick,0xf7dbff21,0,0,0,0,0xf541d1a1,0xf541ceea
tick,0xf7edec90,0,0,0,0,0xf541d1a1,0xf541ceea
tick,0xffffe402,0,0,0,0
profiler,end

View File

@ -0,0 +1,7 @@
[
["exp",4158389888,4158390051],
["fegetexcept",4158374368,4158374389],
["v8::internal::Runtime_Math_exp(v8::internal::Arguments)",135412512,135412608],
["v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)",135235584,135237008],
["v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)",135234064,135235584]
]

View File

@ -0,0 +1,9 @@
Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
[Summary]:
ticks total nonlib name
0 0.0% 0.0% JavaScript
5 38.5% 55.6% C++
0 0.0% 0.0% GC
4 30.8% Shared libraries
2 15.4% Unaccounted

View File

@ -0,0 +1,61 @@
Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
3 23.1% /lib32/libm-2.7.so
1 7.7% ffffe000-fffff000
[JavaScript]:
ticks total nonlib name
[C++]:
ticks total nonlib name
2 15.4% 22.2% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
1 7.7% 11.1% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 7.7% 11.1% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 7.7% 11.1% exp
[Summary]:
ticks total nonlib name
0 0.0% 0.0% JavaScript
5 38.5% 55.6% C++
0 0.0% 0.0% GC
4 30.8% Shared libraries
2 15.4% Unaccounted
[C++ entry points]:
ticks cpp total name
2 40.0% 15.4% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
1 20.0% 7.7% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 20.0% 7.7% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 20.0% 7.7% exp
[Bottom up (heavy) profile]:
Note: percentage shows a share of a particular caller in the total
amount of its parent calls.
Callers occupying less than 1.0% are not shown.
ticks parent name
3 23.1% /lib32/libm-2.7.so
3 100.0% LazyCompile: exp native math.js:41
3 100.0% Script: exp.js
2 15.4% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
2 100.0% LazyCompile: exp native math.js:41
2 100.0% Script: exp.js
2 15.4% UNKNOWN
1 50.0% LazyCompile: exp native math.js:41
1 100.0% Script: exp.js
1 7.7% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 100.0% Script: exp.js
1 7.7% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 100.0% Script: exp.js
1 7.7% ffffe000-fffff000
1 7.7% exp
1 100.0% LazyCompile: exp native math.js:41
1 100.0% Script: exp.js

View File

@ -0,0 +1,68 @@
Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
3 23.1% /lib32/libm-2.7.so
1 7.7% ffffe000-fffff000
[JavaScript]:
ticks total nonlib name
1 7.7% 11.1% LoadIC: j
1 7.7% 11.1% LoadIC: i
[C++]:
ticks total nonlib name
2 15.4% 22.2% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
1 7.7% 11.1% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 7.7% 11.1% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 7.7% 11.1% exp
[Summary]:
ticks total nonlib name
2 15.4% 22.2% JavaScript
5 38.5% 55.6% C++
0 0.0% 0.0% GC
4 30.8% Shared libraries
2 15.4% Unaccounted
[C++ entry points]:
ticks cpp total name
2 40.0% 15.4% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
1 20.0% 7.7% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 20.0% 7.7% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 20.0% 7.7% exp
[Bottom up (heavy) profile]:
Note: percentage shows a share of a particular caller in the total
amount of its parent calls.
Callers occupying less than 1.0% are not shown.
ticks parent name
3 23.1% /lib32/libm-2.7.so
3 100.0% LazyCompile: exp native math.js:41
3 100.0% Script: exp.js
2 15.4% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
2 100.0% LazyCompile: exp native math.js:41
2 100.0% Script: exp.js
2 15.4% UNKNOWN
1 50.0% LazyCompile: exp native math.js:41
1 100.0% Script: exp.js
1 7.7% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 100.0% Script: exp.js
1 7.7% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 100.0% Script: exp.js
1 7.7% ffffe000-fffff000
1 7.7% exp
1 100.0% LazyCompile: exp native math.js:41
1 100.0% Script: exp.js
1 7.7% LoadIC: j
1 7.7% LoadIC: i

View File

@ -0,0 +1,61 @@
Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
3 23.1% /lib32/libm-2.7.so
1 7.7% ffffe000-fffff000
[JavaScript]:
ticks total nonlib name
[C++]:
ticks total nonlib name
2 15.4% 22.2% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
1 7.7% 11.1% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 7.7% 11.1% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 7.7% 11.1% exp
[Summary]:
ticks total nonlib name
0 0.0% 0.0% JavaScript
5 38.5% 55.6% C++
0 0.0% 0.0% GC
4 30.8% Shared libraries
2 15.4% Unaccounted
[C++ entry points]:
ticks cpp total name
2 40.0% 15.4% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
1 20.0% 7.7% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 20.0% 7.7% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 20.0% 7.7% exp
[Bottom up (heavy) profile]:
Note: percentage shows a share of a particular caller in the total
amount of its parent calls.
Callers occupying less than 1.0% are not shown.
ticks parent name
3 23.1% /lib32/libm-2.7.so
3 100.0% LazyCompile: exp native math.js:41
3 100.0% Script: exp.js
2 15.4% v8::internal::Runtime_Math_exp(v8::internal::Arguments)
2 100.0% LazyCompile: exp native math.js:41
2 100.0% Script: exp.js
2 15.4% UNKNOWN
1 50.0% LazyCompile: exp native math.js:41
1 100.0% Script: exp.js
1 7.7% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 100.0% Script: exp.js
1 7.7% v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::internal::String*>::FindEntry(v8::internal::String*)
1 100.0% Script: exp.js
1 7.7% ffffe000-fffff000
1 7.7% exp
1 100.0% LazyCompile: exp native math.js:41
1 100.0% Script: exp.js

View File

@ -0,0 +1,563 @@
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --enable-os-system
// Resources: test/mjsunit/tools/tickprocessor-test-func-info.log
// Resources: test/mjsunit/tools/tickprocessor-test-func-info.log.symbols.json
// Resources: test/mjsunit/tools/tickprocessor-test-large.default
// Resources: test/mjsunit/tools/tickprocessor-test-large.js
// Resources: test/mjsunit/tools/tickprocessor-test-large.log
// Resources: test/mjsunit/tools/tickprocessor-test-large.log.symbols.json
// Resources: test/mjsunit/tools/tickprocessor-test.default
// Resources: test/mjsunit/tools/tickprocessor-test.func-info
// Resources: test/mjsunit/tools/tickprocessor-test.gc-state
// Resources: test/mjsunit/tools/tickprocessor-test.ignore-unknown
// Resources: test/mjsunit/tools/tickprocessor-test.log
// Resources: test/mjsunit/tools/tickprocessor-test.log.symbols.json
// Resources: test/mjsunit/tools/tickprocessor-test.only-summary
// Resources: test/mjsunit/tools/tickprocessor-test.separate-sparkplug-handlers
// Resources: test/mjsunit/tools/tickprocessor-test.separate-bytecodes
// Resources: test/mjsunit/tools/tickprocessor-test.separate-ic
import {
TickProcessor, ArgumentsProcessor, LinuxCppEntriesProvider,
MacOSCppEntriesProvider, WindowsCppEntriesProvider
} from "../../../tools/tickprocessor.mjs";
(function testArgumentsProcessor() {
var p_default = new ArgumentsProcessor([]);
assertTrue(p_default.parse());
assertEquals(p_default.getDefaultResults(), p_default.result());
var p_logFile = new ArgumentsProcessor(['logfile.log']);
assertTrue(p_logFile.parse());
assertEquals('logfile.log', p_logFile.result().logFileName);
var p_platformAndLog = new ArgumentsProcessor(['--windows', 'winlog.log']);
assertTrue(p_platformAndLog.parse());
assertEquals('windows', p_platformAndLog.result().platform);
assertEquals('winlog.log', p_platformAndLog.result().logFileName);
var p_flags = new ArgumentsProcessor(['--gc', '--separate-ic=true']);
assertTrue(p_flags.parse());
assertEquals(TickProcessor.VmStates.GC, p_flags.result().stateFilter);
assertTrue(p_flags.result().separateIc);
var p_flags = new ArgumentsProcessor(['--gc', '--separate-ic=false']);
assertTrue(p_flags.parse());
assertEquals(TickProcessor.VmStates.GC, p_flags.result().stateFilter);
assertFalse(p_flags.result().separateIc);
var p_nmAndLog = new ArgumentsProcessor(['--nm=mn', 'nmlog.log']);
assertTrue(p_nmAndLog.parse());
assertEquals('mn', p_nmAndLog.result().nm);
assertEquals('nmlog.log', p_nmAndLog.result().logFileName);
var p_bad = new ArgumentsProcessor(['--unknown', 'badlog.log']);
assertFalse(p_bad.parse());
})();
await (async function testUnixCppEntriesProvider() {
var oldLoadSymbols = LinuxCppEntriesProvider.prototype.loadSymbols;
// shell executable
LinuxCppEntriesProvider.prototype.loadSymbols = function(libName) {
this.symbols = [[
' U operator delete[](void*)@@GLIBCXX_3.4',
'08049790 T _init',
'08049f50 T _start',
'08139150 00000b4b t v8::internal::Runtime_StringReplaceRegExpWithString(v8::internal::Arguments)',
'08139ca0 000003f1 T v8::internal::Runtime::GetElementOrCharAt(v8::internal::Handle<v8::internal::Object>, unsigned int)',
'0813a0b0 00000855 t v8::internal::Runtime_DebugGetPropertyDetails(v8::internal::Arguments)',
'0818b220 00000036 W v8::internal::RegExpMacroAssembler::CheckPosition(int, v8::internal::Label*)',
' w __gmon_start__',
'081f08a0 00000004 B stdout\n'
].join('\n'), ''];
};
var shell_prov = new LinuxCppEntriesProvider();
var shell_syms = [];
await shell_prov.parseVmSymbols('shell', 0x08048000, 0x081ee000, 0,
(...params) => shell_syms.push(params));
assertEquals(
[['_init', 0x08049790, 0x08049f50],
['_start', 0x08049f50, 0x08139150],
['v8::internal::Runtime_StringReplaceRegExpWithString(v8::internal::Arguments)', 0x08139150, 0x08139150 + 0xb4b],
['v8::internal::Runtime::GetElementOrCharAt(v8::internal::Handle<v8::internal::Object>, unsigned int)', 0x08139ca0, 0x08139ca0 + 0x3f1],
['v8::internal::Runtime_DebugGetPropertyDetails(v8::internal::Arguments)', 0x0813a0b0, 0x0813a0b0 + 0x855],
['v8::internal::RegExpMacroAssembler::CheckPosition(int, v8::internal::Label*)', 0x0818b220, 0x0818b220 + 0x36]],
shell_syms);
// With BigInts
const useBigIntsArgs = [undefined, undefined, undefined, undefined, undefined, true]
var shell_prov = new LinuxCppEntriesProvider(...useBigIntsArgs);
var shell_syms = [];
await shell_prov.parseVmSymbols('shell', 0x08048000n, 0x081ee000n, 0n,
(...params) => shell_syms.push(params));
assertEquals(
[['_init', 0x08049790n, 0x08049f50n],
['_start', 0x08049f50n, 0x08139150n],
['v8::internal::Runtime_StringReplaceRegExpWithString(v8::internal::Arguments)', 0x08139150n, 0x08139150n + 0xb4bn],
['v8::internal::Runtime::GetElementOrCharAt(v8::internal::Handle<v8::internal::Object>, unsigned int)', 0x08139ca0n, 0x08139ca0n + 0x3f1n],
['v8::internal::Runtime_DebugGetPropertyDetails(v8::internal::Arguments)', 0x0813a0b0n, 0x0813a0b0n + 0x855n],
['v8::internal::RegExpMacroAssembler::CheckPosition(int, v8::internal::Label*)', 0x0818b220n, 0x0818b220n + 0x36n]],
shell_syms);
// libc library
LinuxCppEntriesProvider.prototype.loadSymbols = function(libName) {
this.symbols = [[
'000162a0 00000005 T __libc_init_first',
'0002a5f0 0000002d T __isnan',
'0002a5f0 0000002d W isnan',
'0002aaa0 0000000d W scalblnf',
'0002aaa0 0000000d W scalbnf',
'0011a340 00000048 T __libc_thread_freeres',
'00128860 00000024 R _itoa_lower_digits\n'].join('\n'), ''];
};
var libc_prov = new LinuxCppEntriesProvider();
var libc_syms = [];
await libc_prov.parseVmSymbols('libc', 0xf7c5c000, 0xf7da5000, 0,
(...params) => libc_syms.push(params));
var libc_ref_syms = [['__libc_init_first', 0x000162a0, 0x000162a0 + 0x5],
['__isnan', 0x0002a5f0, 0x0002a5f0 + 0x2d],
['scalblnf', 0x0002aaa0, 0x0002aaa0 + 0xd],
['__libc_thread_freeres', 0x0011a340, 0x0011a340 + 0x48]];
for (var i = 0; i < libc_ref_syms.length; ++i) {
libc_ref_syms[i][1] += 0xf7c5c000;
libc_ref_syms[i][2] += 0xf7c5c000;
}
assertEquals(libc_ref_syms, libc_syms);
// Android library with zero length duplicates.
LinuxCppEntriesProvider.prototype.loadSymbols = function(libName) {
this.symbols = [[
'00000000013a1088 0000000000000224 t v8::internal::interpreter::BytecodeGenerator::BytecodeGenerator(v8::internal::UnoptimizedCompilationInfo*)',
'00000000013a1088 0000000000000224 t v8::internal::interpreter::BytecodeGenerator::BytecodeGenerator(v8::internal::UnoptimizedCompilationInfo*)',
'00000000013a12ac t $x.4',
'00000000013a12ac 00000000000000d0 t v8::internal::interpreter::BytecodeGenerator::FinalizeBytecode(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Script>)',
'00000000013a137c t $x.5',
'00000000013a137c 0000000000000528 t v8::internal::interpreter::BytecodeGenerator::AllocateDeferredConstants(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Script>)',
'00000000013a1578 N $d.46',
'00000000013a18a4 t $x.6',
'00000000013a18a4 0000000000000 t v8::internal::interpreter::BytecodeGenerator::GlobalDeclarationsBuilder::AllocateDeclarations(v8::internal::UnoptimizedCompilationInfo*, v8::internal::Handle<v8::internal::Script>, v8::internal::Isolate*)',
'00000000013a19e0 t $x.7',
'00000000013a19e0 0000000000000244 t v8::internal::interpreter::BytecodeGenerator::GenerateBytecode(unsigned long)',
'00000000013a1a88 N $d.7',
'00000000013a1ac8 N $d.5',
'00000000013a1af8 N $d.35',
'00000000013a1c24 t $x.8',
'00000000013a1c24 000000000000009c t v8::internal::interpreter::BytecodeGenerator::ContextScope::ContextScope(v8::internal::interpreter::BytecodeGenerator*, v8::internal::Scope*)\n',
].join('\n'), ''];
};
var android_prov = new LinuxCppEntriesProvider();
var android_syms = [];
await android_prov.parseVmSymbols('libmonochrome', 0xf7c5c000, 0xf9c5c000, 0,
(...params) => android_syms.push(params));
var android_ref_syms = [
['v8::internal::interpreter::BytecodeGenerator::BytecodeGenerator(v8::internal::UnoptimizedCompilationInfo*)', 0x013a1088, 0x013a1088 + 0x224],
['v8::internal::interpreter::BytecodeGenerator::FinalizeBytecode(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Script>)', 0x013a12ac, 0x013a12ac + 0xd0],
['v8::internal::interpreter::BytecodeGenerator::AllocateDeferredConstants(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Script>)', 0x013a137c, 0x013a137c + 0x528],
['v8::internal::interpreter::BytecodeGenerator::GlobalDeclarationsBuilder::AllocateDeclarations(v8::internal::UnoptimizedCompilationInfo*, v8::internal::Handle<v8::internal::Script>, v8::internal::Isolate*)', 0x013a18a4, 0x013a18a4 + 0x13c],
['v8::internal::interpreter::BytecodeGenerator::GenerateBytecode(unsigned long)', 0x013a19e0, 0x013a19e0 + 0x244],
['v8::internal::interpreter::BytecodeGenerator::ContextScope::ContextScope(v8::internal::interpreter::BytecodeGenerator*, v8::internal::Scope*)', 0x013a1c24, 0x013a1c24 + 0x9c],
];
for (var i = 0; i < android_ref_syms.length; ++i) {
android_ref_syms[i][1] += 0xf7c5c000;
android_ref_syms[i][2] += 0xf7c5c000;
}
assertEquals(android_ref_syms, android_syms);
// With BigInts
var android_prov = new LinuxCppEntriesProvider(...useBigIntsArgs);
var android_syms = [];
await android_prov.parseVmSymbols('libmonochrome', 0xf7c5c000n, 0xf9c5c000n, 0n,
(...params) => android_syms.push(params));
var android_ref_syms_bigints = android_ref_syms.map(entry => [
entry[0], BigInt(entry[1]), BigInt(entry[2])
])
assertEquals(android_ref_syms_bigints, android_syms);
LinuxCppEntriesProvider.prototype.loadSymbols = oldLoadSymbols;
})();
await (async function testMacOSCppEntriesProvider() {
var oldLoadSymbols = MacOSCppEntriesProvider.prototype.loadSymbols;
// shell executable
MacOSCppEntriesProvider.prototype.loadSymbols = function(libName) {
this.symbols = [[
' operator delete[]',
'00001000 __mh_execute_header',
'00001b00 start',
'00001b40 dyld_stub_binding_helper',
'0011b710 v8::internal::RegExpMacroAssembler::CheckPosition',
'00134250 v8::internal::Runtime_StringReplaceRegExpWithString',
'00137220 v8::internal::Runtime::GetElementOrCharAt',
'00137400 v8::internal::Runtime_DebugGetPropertyDetails\n'
].join('\n'), ''];
};
var shell_prov = new MacOSCppEntriesProvider();
var shell_syms = [];
await shell_prov.parseVmSymbols('shell', 0x00001b00, 0x00163256, 0x100,
(...params) => shell_syms.push(params));
assertEquals(
[['start', 0x00001c00, 0x00001c40],
['dyld_stub_binding_helper', 0x00001c40, 0x0011b810],
['v8::internal::RegExpMacroAssembler::CheckPosition', 0x0011b810, 0x00134350],
['v8::internal::Runtime_StringReplaceRegExpWithString', 0x00134350, 0x00137320],
['v8::internal::Runtime::GetElementOrCharAt', 0x00137320, 0x00137500],
['v8::internal::Runtime_DebugGetPropertyDetails', 0x00137500, 0x00163256]],
shell_syms);
// stdc++ library
MacOSCppEntriesProvider.prototype.loadSymbols = function(libName) {
this.symbols = [[
'0000107a __gnu_cxx::balloc::__mini_vector<std::pair<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*, __gnu_cxx::bitmap_allocator<char>::_Alloc_block*> >::__mini_vector',
'0002c410 std::basic_streambuf<char, std::char_traits<char> >::pubseekoff',
'0002c488 std::basic_streambuf<char, std::char_traits<char> >::pubseekpos',
'000466aa ___cxa_pure_virtual\n'].join('\n'), ''];
};
var stdc_prov = new MacOSCppEntriesProvider();
var stdc_syms = [];
await stdc_prov.parseVmSymbols('stdc++', 0x95728fb4, 0x95770005, 0,
(...params) => stdc_syms.push(params));
var stdc_ref_syms = [['__gnu_cxx::balloc::__mini_vector<std::pair<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*, __gnu_cxx::bitmap_allocator<char>::_Alloc_block*> >::__mini_vector', 0x0000107a, 0x0002c410],
['std::basic_streambuf<char, std::char_traits<char> >::pubseekoff', 0x0002c410, 0x0002c488],
['std::basic_streambuf<char, std::char_traits<char> >::pubseekpos', 0x0002c488, 0x000466aa],
['___cxa_pure_virtual', 0x000466aa, 0x95770005 - 0x95728fb4]];
for (var i = 0; i < stdc_ref_syms.length; ++i) {
stdc_ref_syms[i][1] += 0x95728fb4;
stdc_ref_syms[i][2] += 0x95728fb4;
}
assertEquals(stdc_ref_syms, stdc_syms);
// With BigInts
const useBigIntsArgs = [undefined, undefined, undefined, undefined, undefined, true];
var stdc_prov = new MacOSCppEntriesProvider(...useBigIntsArgs);
var stdc_syms = [];
await stdc_prov.parseVmSymbols('stdc++', 0x95728fb4n, 0x95770005n, 0n,
(...params) => stdc_syms.push(params));
var stdc_ref_syms_bigints = stdc_ref_syms.map(entry => [
entry[0], BigInt(entry[1]), BigInt(entry[2])
])
assertEquals(stdc_ref_syms_bigints, stdc_syms);
MacOSCppEntriesProvider.prototype.loadSymbols = oldLoadSymbols;
})();
await (async function testWindowsCppEntriesProvider() {
var oldLoadSymbols = WindowsCppEntriesProvider.prototype.loadSymbols;
WindowsCppEntriesProvider.prototype.loadSymbols = function(libName) {
this.symbols = [
' Start Length Name Class',
' 0001:00000000 000ac902H .text INSTRUCTION_STREAM',
' 0001:000ac910 000005e2H .text$yc INSTRUCTION_STREAM',
' Address Publics by Value Rva+Base Lib:Object',
' 0000:00000000 __except_list 00000000 <absolute>',
' 0001:00000000 ?ReadFile@@YA?AV?$Handle@VString@v8@@@v8@@PBD@Z 00401000 f shell.obj',
' 0001:000000a0 ?Print@@YA?AV?$Handle@VValue@v8@@@v8@@ABVArguments@2@@Z 004010a0 f shell.obj',
' 0001:00001230 ??1UTF8Buffer@internal@v8@@QAE@XZ 00402230 f v8_snapshot:scanner.obj',
' 0001:00001230 ??1Utf8Value@String@v8@@QAE@XZ 00402230 f v8_snapshot:api.obj',
' 0001:000954ba __fclose_nolock 004964ba f LIBCMT:fclose.obj',
' 0002:00000000 __imp__SetThreadPriority@8 004af000 kernel32:KERNEL32.dll',
' 0003:00000418 ?in_use_list_@PreallocatedStorage@internal@v8@@0V123@A 00544418 v8_snapshot:allocation.obj',
' Static symbols',
' 0001:00000b70 ?DefaultFatalErrorHandler@v8@@YAXPBD0@Z 00401b70 f v8_snapshot:api.obj',
' 0001:000010b0 ?EnsureInitialized@v8@@YAXPBD@Z 004020b0 f v8_snapshot:api.obj',
' 0001:000ad17b ??__Fnomem@?5???2@YAPAXI@Z@YAXXZ 004ae17b f LIBCMT:new.obj'
].join('\r\n');
};
var shell_prov = new WindowsCppEntriesProvider();
var shell_syms = [];
await shell_prov.parseVmSymbols('shell.exe', 0x00400000, 0x0057c000, 0,
(...params) => shell_syms.push(params));
assertEquals(
[['ReadFile', 0x00401000, 0x004010a0],
['Print', 0x004010a0, 0x00402230],
['v8::String::?1Utf8Value', 0x00402230, 0x004964ba],
['v8::DefaultFatalErrorHandler', 0x00401b70, 0x004020b0],
['v8::EnsureInitialized', 0x004020b0, 0x0057c000]],
shell_syms);
// With BigInts
const useBigIntsArgs = [undefined, undefined, undefined, undefined, undefined, true];
var shell_prov = new WindowsCppEntriesProvider(...useBigIntsArgs);
var shell_syms = [];
await shell_prov.parseVmSymbols('shell.exe', 0x00400000n, 0x0057c000n, 0n,
(...params) => shell_syms.push(params));
assertEquals(
[['ReadFile', 0x00401000n, 0x004010a0n],
['Print', 0x004010a0n, 0x00402230n],
['v8::String::?1Utf8Value', 0x00402230n, 0x004964ban],
['v8::DefaultFatalErrorHandler', 0x00401b70n, 0x004020b0n],
['v8::EnsureInitialized', 0x004020b0n, 0x0057c000n]],
shell_syms);
WindowsCppEntriesProvider.prototype.loadSymbols = oldLoadSymbols;
})();
// http://code.google.com/p/v8/issues/detail?id=427
await (async function testWindowsProcessExeAndDllMapFile() {
function exeSymbols(exeName) {
return [
' 0000:00000000 ___ImageBase 00400000 <linker-defined>',
' 0001:00000780 ?RunMain@@YAHHQAPAD@Z 00401780 f shell.obj',
' 0001:00000ac0 _main 00401ac0 f shell.obj',
''
].join('\r\n');
}
function dllSymbols(dllName) {
return [
' 0000:00000000 ___ImageBase 01c30000 <linker-defined>',
' 0001:00000780 _DllMain@12 01c31780 f libcmt:dllmain.obj',
' 0001:00000ac0 ___DllMainCRTStartup 01c31ac0 f libcmt:dllcrt0.obj',
''
].join('\r\n');
}
var oldRead = read;
read = exeSymbols;
var exe_exe_syms = [];
await (new WindowsCppEntriesProvider()).parseVmSymbols(
'chrome.exe', 0x00400000, 0x00472000, 0,
(...params) => exe_exe_syms.push(params));
assertEquals(
[['RunMain', 0x00401780, 0x00401ac0],
['_main', 0x00401ac0, 0x00472000]],
exe_exe_syms, '.exe with .exe symbols');
// With BigInts
read = exeSymbols;
const useBigIntsArgs = [undefined, undefined, undefined, undefined, undefined, true];
var exe_exe_syms = [];
await (new WindowsCppEntriesProvider(...useBigIntsArgs)).parseVmSymbols(
'chrome.exe', 0x00400000n, 0x00472000n, 0n,
(...params) => exe_exe_syms.push(params));
assertEquals(
[['RunMain', 0x00401780n, 0x00401ac0n],
['_main', 0x00401ac0n, 0x00472000n]],
exe_exe_syms, '.exe with .exe symbols');
read = dllSymbols;
var exe_dll_syms = [];
await (new WindowsCppEntriesProvider()).parseVmSymbols(
'chrome.exe', 0x00400000, 0x00472000, 0,
(...params) => exe_dll_syms.push(params));
assertEquals(
[],
exe_dll_syms, '.exe with .dll symbols');
read = dllSymbols;
var dll_dll_syms = [];
await (new WindowsCppEntriesProvider()).parseVmSymbols(
'chrome.dll', 0x01c30000, 0x02b80000, 0,
(...params) => dll_dll_syms.push(params));
assertEquals(
[['_DllMain@12', 0x01c31780, 0x01c31ac0],
['___DllMainCRTStartup', 0x01c31ac0, 0x02b80000]],
dll_dll_syms, '.dll with .dll symbols');
// With BigInts
read = dllSymbols;
var dll_dll_syms = [];
await (new WindowsCppEntriesProvider(...useBigIntsArgs)).parseVmSymbols(
'chrome.dll', 0x01c30000n, 0x02b80000n, 0n,
(...params) => dll_dll_syms.push(params));
assertEquals(
[['_DllMain@12', 0x01c31780n, 0x01c31ac0n],
['___DllMainCRTStartup', 0x01c31ac0n, 0x02b80000n]],
dll_dll_syms, '.dll with .dll symbols');
read = exeSymbols;
var dll_exe_syms = [];
await (new WindowsCppEntriesProvider()).parseVmSymbols(
'chrome.dll', 0x01c30000, 0x02b80000, 0,
(...params) => dll_exe_syms.push(params));
assertEquals(
[],
dll_exe_syms, '.dll with .exe symbols');
read = oldRead;
})();
class CppEntriesProviderMock {
constructor(filename, useBigIntAddresses=false) {
this.isLoaded = false;
this.symbols = JSON.parse(d8.file.read(filename));
this.parseAddr = useBigIntAddresses ? BigInt : parseInt;
}
parseVmSymbols(name, startAddr, endAddr, slideAddr, symbolAdder) {
if (this.isLoaded) return;
this.isLoaded = true;
for (let symbolInfo of this.symbols) {
const [name, start, end] = symbolInfo;
symbolAdder.call(null, name, this.parseAddr(start), this.parseAddr(end))
}
}
}
class PrintMonitor {
constructor(outputOrFileName) {
this.expectedOut = outputOrFileName;
this.outputFile = undefined;
if (typeof outputOrFileName == 'string') {
this.expectedOut = this.loadExpectedOutput(outputOrFileName)
this.outputFile = outputOrFileName;
}
let expectedOut = this.expectedOut;
let outputPos = 0;
let diffs = this.diffs = [];
let realOut = this.realOut = [];
let unexpectedOut = this.unexpectedOut = null;
this.oldPrint = print;
print = function(str) {
const strSplit = str.split('\n');
for (let i = 0; i < strSplit.length; ++i) {
const s = strSplit[i];
realOut.push(s);
if (outputPos < expectedOut.length) {
if (expectedOut[outputPos] != s) {
diffs.push('line ' + outputPos + ': expected <' +
expectedOut[outputPos] + '> found <' + s + '>\n');
}
outputPos++;
} else {
unexpectedOut = true;
}
}
};
}
loadExpectedOutput(fileName) {
const output = d8.file.read(fileName);
return output.split('\n');
}
finish() {
print = this.oldPrint;
if (this.diffs.length == 0 && this.unexpectedOut == null) return;
console.log("===== actual output: =====");
console.log(this.realOut.join('\n'));
console.log("===== expected output: =====");
if (this.outputFile) {
console.log("===== File: " + this.outputFile + " =====");
}
console.log(this.expectedOut.join('\n'));
if (this.diffs.length > 0) {
this.diffs.forEach(line => console.log(line))
assertEquals([], this.diffs);
}
assertNull(this.unexpectedOut);
}
}
await (async function testProcessing() {
const testData = {
'Default': [
'tickprocessor-test.log', 'tickprocessor-test.default',
['--separate-ic=false']],
'SeparateBytecodes': [
'tickprocessor-test.log', 'tickprocessor-test.separate-bytecodes',
['--separate-ic=false', '--separate-bytecodes']],
'SeparateSparkplugHandlers': [
'tickprocessor-test.log', 'tickprocessor-test.separate-sparkplug-handlers',
['--separate-ic=false', '--separate-sparkplug-handlers']],
'SeparateIc': [
'tickprocessor-test.log', 'tickprocessor-test.separate-ic',
['--separate-ic=true']],
'IgnoreUnknown': [
'tickprocessor-test.log', 'tickprocessor-test.ignore-unknown',
['--separate-ic=false', '--ignore-unknown']],
'GcState': [
'tickprocessor-test.log', 'tickprocessor-test.gc-state', ['-g']],
'OnlySummary': [
'tickprocessor-test.log', 'tickprocessor-test.only-summary',
['--separate-ic=false', '--only-summary']],
'FunctionInfo': [
'tickprocessor-test-func-info.log', 'tickprocessor-test.func-info',
['']
],
'DefaultLarge': [
'tickprocessor-test-large.log', 'tickprocessor-test-large.default'],
};
for (var testName in testData) {
await testTickProcessor(testName, ...testData[testName]);
}
})();
async function testTickProcessor(testName, logInput, refOutput, args=[]) {
console.log('=== testProcessing-' + testName + ' ===');
await testTickProcessorBasic(logInput, refOutput, args);
// Using BigInt address should not affect the output.
console.log('=== testProcessing-' + testName + '-bigint-addresses ===');
await testTickProcessorBasic(
logInput, refOutput, [...args, '--use-bigint-addresses']);
}
async function testTickProcessorBasic(
logInput, refOutput, args=[]) {
// /foo/bar/tickprocessor.mjs => /foo/bar/
const dir = import.meta.url.split("/").slice(0, -1).join('/') + '/';
const params = ArgumentsProcessor.process(args);
await testExpectations(dir, logInput, refOutput, params);
// TODO(cbruni): enable again after it works on bots
// await testEndToEnd(dir, 'tickprocessor-test-large.js', refOutput, params);
}
async function testExpectations(dir, logInput, refOutput, params) {
const symbolsFile = dir + logInput + '.symbols.json';
const cppEntries = new CppEntriesProviderMock(
symbolsFile, params.useBigIntAddresses);
const tickProcessor = TickProcessor.fromParams(params, cppEntries);
const printMonitor = new PrintMonitor(dir + refOutput);
await tickProcessor.processLogFileInTest(dir + logInput);
tickProcessor.printStatistics();
printMonitor.finish();
};
async function testEndToEnd(dir, sourceFile, ignoredRefOutput, params) {
// This test only works on linux.
if (!os?.system) return;
if (os.name !== 'linux' && os.name !== 'macos') return;
params.platform = os.name;
const tmpLogFile= `/var/tmp/${Date.now()}.v8.log`
const result = os.system(
os.d8Path, ['--prof', `--logfile=${tmpLogFile}`, dir + sourceFile]);
const tickProcessor = TickProcessor.fromParams(params);
// We will not always get the same ticks due to timing on bots,
// hence we cannot properly compare output expectations.
// Let's just use a dummy file and only test whether we don't throw.
const printMonitor = new PrintMonitor(dir + ignoredRefOutput);
await tickProcessor.processLogFileInTest(tmpLogFile);
tickProcessor.printStatistics();
}

171
deps/v8/test/mjsunit/tools/timeline.mjs vendored Normal file
View File

@ -0,0 +1,171 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { Timeline } from "../../../tools/system-analyzer/timeline.mjs";
import { LogEntry} from "../../../tools/system-analyzer/log/log.mjs";
class TestLogEntry extends LogEntry {
toString() {
return `TestLogEntry(${this.id}, ${this.time})`;
}
}
(function testTimeline() {
let timeline = new Timeline();
assertTrue(timeline.isEmpty());
let id1 = "0x3e7e082470cd";
let id2 = "0x3e7e082470ad";
let time = 10;
let entry1 = new TestLogEntry(id1, time + 0);
let entry2 = new TestLogEntry(id1, time + 1);
let entry3 = new TestLogEntry(id1, time + 2);
let entry4 = new TestLogEntry(id1, time + 3);
let entry5 = new TestLogEntry(id2, time + 3);
let entry6 = new TestLogEntry(id1, time + 4);
timeline.push(entry1);
assertFalse(timeline.isEmpty());
assertEquals(timeline.first(), entry1);
assertEquals(timeline.at(0), entry1);
assertEquals(timeline.last(), entry1);
timeline.push(entry2);
assertEquals(timeline.first(), entry1);
assertEquals(timeline.at(1), entry2);
assertEquals(timeline.last(), entry2);
timeline.push(entry3);
timeline.push(entry4);
timeline.push(entry5);
timeline.push(entry6);
assertEquals(timeline.first(), entry1);
assertEquals(timeline.at(0), entry1);
assertEquals(timeline.at(1), entry2);
assertEquals(timeline.at(2), entry3);
assertEquals(timeline.at(3), entry4);
assertEquals(timeline.at(4), entry5);
assertEquals(timeline.at(5), entry6);
assertEquals(timeline.last(), entry6);
assertEquals(timeline.length, 6);
assertEquals(timeline.all.length, 6);
assertEquals(timeline.startTime, entry1.time);
assertEquals(timeline.endTime, entry6.time);
assertEquals(timeline.duration(), 4);
assertEquals(timeline.findFirst(time - 1), 0);
assertEquals(timeline.findFirst(time + 0), 0);
assertEquals(timeline.findFirst(time + 1), 1);
assertEquals(timeline.findFirst(time + 2), 2);
assertEquals(timeline.findFirst(time + 3), 3);
assertEquals(timeline.findFirst(time + 4), 5);
assertEquals(timeline.findFirst(time + 5), 5);
assertEquals(timeline.findFirst(time + 2.00), 2);
assertEquals(timeline.findFirst(time + 2.01), 3);
assertEquals(timeline.findFirst(time + 2.90), 3);
assertEquals(timeline.findFirst(time + 3.01), 5);
assertEquals(timeline.findFirst(time + 3.90), 5);
assertEquals(timeline.findFirst(time + 4.00), 5);
assertEquals(timeline.findLast(time - 1), -1);
assertEquals(timeline.findLast(time + 0), 0);
assertEquals(timeline.findLast(time + 1), 1);
assertEquals(timeline.findLast(time + 2), 2);
assertEquals(timeline.findLast(time + 3), 4);
assertEquals(timeline.findLast(time + 4), 5);
assertEquals(timeline.findLast(time + 5), 5);
assertEquals(timeline.findLast(time + 2.00), 2);
assertEquals(timeline.findLast(time + 2.01), 2);
assertEquals(timeline.findLast(time + 2.90), 2);
assertEquals(timeline.findLast(time + 3.01), 4);
assertEquals(timeline.findLast(time + 3.90), 4);
assertEquals(timeline.findLast(time + 4.00), 5);
let startTime = time;
let endTime = time + 2;
timeline.selectTimeRange(startTime, endTime);
assertArrayEquals(timeline.selection.startTime, startTime);
assertArrayEquals(timeline.selection.endTime, endTime);
assertArrayEquals(timeline.selection.values, [entry1, entry2]);
let entryIdx = timeline.find(time + 1);
let entry = timeline.at(entryIdx);
assertEquals(entry.time, time + 1);
})();
(function testChunks() {
const id1 = "0x3e7e082470cd";
const time = 10;
const entry1 = new TestLogEntry(id1, time + 0);
const entry2 = new TestLogEntry(id1, time + 1);
const entry3 = new TestLogEntry(id1, time + 2);
const entry4 = new TestLogEntry(id1, time + 3);
const entries = [entry1, entry2, entry3, entry4];
const timeline1 = new Timeline(TestLogEntry, entries);
assertEquals(timeline1.length, 4);
assertEquals(timeline1.startTime, time);
assertEquals(timeline1.endTime, time + 3);
const chunks1_1 = timeline1.chunks(1);
assertEquals(chunks1_1.length, 1);
assertEquals(chunks1_1[0].start, timeline1.startTime);
assertEquals(chunks1_1[0].end, timeline1.endTime);
assertArrayEquals(chunks1_1[0].items, entries);
const chunks1_4 = timeline1.chunks(4);
assertEquals(chunks1_4.length, 4);
assertEquals(chunks1_4[0].start, timeline1.startTime);
assertArrayEquals(chunks1_4[0].items, [entry1]);
assertEquals(chunks1_4[1].start, 10.75);
assertArrayEquals(chunks1_4[1].items, [entry2]);
assertEquals(chunks1_4[2].start, 11.5);
assertArrayEquals(chunks1_4[2].items, [entry3]);
assertEquals(chunks1_4[3].end, timeline1.endTime);
assertArrayEquals(chunks1_4[3].items, [entry4]);
const timeline2 = new Timeline(TestLogEntry, entries, 0, 100);
assertEquals(timeline2.length, 4);
assertEquals(timeline2.startTime, 0);
assertEquals(timeline2.endTime, 100);
assertEquals(timeline2.duration(), 100);
const chunks2_1 = timeline2.chunks(1);
assertEquals(chunks2_1.length, 1);
assertEquals(chunks2_1[0].start, timeline2.startTime);
assertEquals(chunks2_1[0].end, timeline2.endTime);
assertArrayEquals(chunks1_1[0].items, entries);
const chunks2_2 = timeline2.chunks(2);
assertEquals(chunks2_2.length, 2);
assertEquals(chunks2_2[0].start, 0);
assertEquals(chunks2_2[0].end, 50);
assertArrayEquals(chunks2_2[0].items, entries);
assertEquals(chunks2_2[1].start, 50);
assertEquals(chunks2_2[1].end, 100);
assertArrayEquals(chunks2_2[1].items, []);
const chunks2_4 = timeline2.chunks(4);
assertEquals(chunks2_4.length, 4);
assertEquals(chunks2_4[0].start, 0);
assertEquals(chunks2_4[0].end, 25);
assertArrayEquals(chunks2_4[0].items, entries);
assertEquals(chunks2_4[1].start, 25);
assertEquals(chunks2_4[1].end, 50);
assertArrayEquals(chunks2_4[1].items, []);
assertEquals(chunks2_4[2].start, 50);
assertEquals(chunks2_4[2].end, 75);
assertArrayEquals(chunks2_4[2].items, []);
assertEquals(chunks2_4[3].start, 75);
assertEquals(chunks2_4[3].end, 100);
assertArrayEquals(chunks2_4[3].items, []);
})();