| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b266adb commit 3ea53c5
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | 37 | # Reset this number to 0 on major V8 upgrades. | |
| 38 | 38 | # Increment by one for each non-official patch applied to deps/v8. | |
| 39 | - 'v8_embedder_string': '-node.22', | ||
| 39 | + 'v8_embedder_string': '-node.23', | ||
| 40 | 40 | ||
| 41 | 41 | ##### V8 defaults for Node.js ##### | |
| 42 | 42 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,7 @@ | |||
| 12 | 12 | #include "src/base/numbers/dtoa.h" | |
| 13 | 13 | #include "src/base/numbers/strtod.h" | |
| 14 | 14 | #include "src/base/platform/wrappers.h" | |
| 15 | + #include "src/base/small-vector.h" | ||
| 15 | 16 | #include "src/bigint/bigint.h" | |
| 16 | 17 | #include "src/common/assert-scope.h" | |
| 17 | 18 | #include "src/handles/handles.h" | |
@@ -970,6 +971,23 @@ class StringToBigIntHelper : public StringToIntHelper<IsolateT> { | |||
| 970 | 971 | UNREACHABLE(); | |
| 971 | 972 | } | |
| 972 | 973 | ||
| 974 | + // Used for converting BigInt literals. The scanner has already checked | ||
| 975 | + // that the literal is valid and not too big, so this always succeeds. | ||
| 976 | + std::unique_ptr<char[]> DecimalString(bigint::Processor* processor) { | ||
| 977 | + DCHECK_EQ(behavior_, Behavior::kLiteral); | ||
| 978 | + this->ParseInt(); | ||
| 979 | + DCHECK_EQ(this->state(), State::kDone); | ||
| 980 | + int num_digits = accumulator_.ResultLength(); | ||
| 981 | + base::SmallVector<bigint::digit_t, 8> digit_storage(num_digits); | ||
| 982 | + bigint::RWDigits digits(digit_storage.data(), num_digits); | ||
| 983 | + processor->FromString(digits, &accumulator_); | ||
| 984 | + int num_chars = bigint::ToStringResultLength(digits, 10, false); | ||
| 985 | + std::unique_ptr<char[]> out(new char[num_chars + 1]); | ||
| 986 | + processor->ToString(out.get(), &num_chars, digits, 10, false); | ||
| 987 | + out[num_chars] = '\0'; | ||
| 988 | + return out; | ||
| 989 | + } | ||
| 990 | + | ||
| 973 | 991 | private: | |
| 974 | 992 | template <class Char> | |
| 975 | 993 | void ParseInternal(Char start) { | |
@@ -1018,6 +1036,13 @@ template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) | |||
| 1018 | 1036 | MaybeHandle<BigInt> BigIntLiteral(LocalIsolate* isolate, | |
| 1019 | 1037 | const char* string); | |
| 1020 | 1038 | ||
| 1039 | + std::unique_ptr<char[]> BigIntLiteralToDecimal( | ||
| 1040 | + LocalIsolate* isolate, base::Vector<const uint8_t> literal) { | ||
| 1041 | + StringToBigIntHelper<LocalIsolate> helper(nullptr, literal.begin(), | ||
| 1042 | + literal.length()); | ||
| 1043 | + return helper.DecimalString(isolate->bigint_processor()); | ||
| 1044 | + } | ||
| 1045 | + | ||
| 1021 | 1046 | const char* DoubleToCString(double v, base::Vector<char> buffer) { | |
| 1022 | 1047 | switch (FPCLASSIFY_NAMESPACE::fpclassify(v)) { | |
| 1023 | 1048 | case FP_NAN: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,6 +119,8 @@ const int kDoubleToCStringMinBufferSize = 100; | |||
| 119 | 119 | V8_EXPORT_PRIVATE const char* DoubleToCString(double value, | |
| 120 | 120 | base::Vector<char> buffer); | |
| 121 | 121 | ||
| 122 | + V8_EXPORT_PRIVATE std::unique_ptr<char[]> BigIntLiteralToDecimal( | ||
| 123 | + LocalIsolate* isolate, base::Vector<const uint8_t> literal); | ||
| 122 | 124 | // Convert an int to a null-terminated string. The returned string is | |
| 123 | 125 | // located inside the buffer, but not necessarily at the start. | |
| 124 | 126 | V8_EXPORT_PRIVATE const char* IntToCString(int n, base::Vector<char> buffer); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2288,7 +2288,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseProperty( | |||
| 2288 | 2288 | ||
| 2289 | 2289 | case Token::BIGINT: { | |
| 2290 | 2290 | Consume(Token::BIGINT); | |
| 2291 | - prop_info->name = impl()->GetSymbol(); | ||
| 2291 | + prop_info->name = impl()->GetBigIntAsSymbol(); | ||
| 2292 | 2292 | is_array_index = impl()->IsArrayIndex(prop_info->name, &index); | |
| 2293 | 2293 | break; | |
| 2294 | 2294 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -247,6 +247,16 @@ bool Parser::CollapseNaryExpression(Expression** x, Expression* y, | |||
| 247 | 247 | return true; | |
| 248 | 248 | } | |
| 249 | 249 | ||
| 250 | + const AstRawString* Parser::GetBigIntAsSymbol() { | ||
| 251 | + base::Vector<const uint8_t> literal = scanner()->BigIntLiteral(); | ||
| 252 | + if (literal[0] != '0' || literal.length() == 1) { | ||
| 253 | + return ast_value_factory()->GetOneByteString(literal); | ||
| 254 | + } | ||
| 255 | + std::unique_ptr<char[]> decimal = | ||
| 256 | + BigIntLiteralToDecimal(local_isolate_, literal); | ||
| 257 | + return ast_value_factory()->GetOneByteString(decimal.get()); | ||
| 258 | + } | ||
| 259 | + | ||
| 250 | 260 | Expression* Parser::BuildUnaryExpression(Expression* expression, | |
| 251 | 261 | Token::Value op, int pos) { | |
| 252 | 262 | DCHECK_NOT_NULL(expression); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -790,6 +790,8 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { | |||
| 790 | 790 | return ast_value_factory()->GetOneByteString(string); | |
| 791 | 791 | } | |
| 792 | 792 | ||
| 793 | + const AstRawString* GetBigIntAsSymbol(); | ||
| 794 | + | ||
| 793 | 795 | class ThisExpression* ThisExpression() { | |
| 794 | 796 | UseThis(); | |
| 795 | 797 | return factory()->ThisExpression(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1522,6 +1522,10 @@ class PreParser : public ParserBase<PreParser> { | |||
| 1522 | 1522 | return PreParserIdentifier::Default(); | |
| 1523 | 1523 | } | |
| 1524 | 1524 | ||
| 1525 | + V8_INLINE PreParserIdentifier GetBigIntAsSymbol() const { | ||
| 1526 | + return PreParserIdentifier::Default(); | ||
| 1527 | + } | ||
| 1528 | + | ||
| 1525 | 1529 | V8_INLINE PreParserExpression ThisExpression() { | |
| 1526 | 1530 | UseThis(); | |
| 1527 | 1531 | return PreParserExpression::This(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -336,6 +336,9 @@ class V8_EXPORT_PRIVATE Scanner { | |||
| 336 | 336 | AstValueFactory* ast_value_factory) const; | |
| 337 | 337 | ||
| 338 | 338 | double DoubleValue(); | |
| 339 | + base::Vector<const uint8_t> BigIntLiteral() const { | ||
| 340 | + return literal_one_byte_string(); | ||
| 341 | + } | ||
| 339 | 342 | ||
| 340 | 343 | const char* CurrentLiteralAsCString(Zone* zone) const; | |
| 341 | 344 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,3 +7,26 @@ assertEquals(it, 1); | |||
| 7 | 7 | ||
| 8 | 8 | var { 999999999999999999n: it } = { 999999999999999999n: 1 }; // greater than max safe integer | |
| 9 | 9 | assertEquals(it, 1); | |
| 10 | + | ||
| 11 | + var obj = { 0xfffffffffffffffffffffn: 1}; | ||
| 12 | + assertEquals(1, obj["19342813113834066795298815"]); | ||
| 13 | + | ||
| 14 | + var obj2 = {0o777777777777777777777777777n: 1}; | ||
| 15 | + assertEquals(1, obj2["2417851639229258349412351"]); | ||
| 16 | + | ||
| 17 | + var obj3 = { 0x4n: 'hi' }; | ||
| 18 | + | ||
| 19 | + assertEquals('hi', obj3[4]); | ||
| 20 | + assertEquals(undefined, obj3["0x4"]); | ||
| 21 | + | ||
| 22 | + let obj4 = | ||
| 23 | + {12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890n: 1}; | ||
| 24 | + assertEquals( | ||
| 25 | + 1, | ||
| 26 | + obj4["12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"]); | ||
| 27 | + | ||
| 28 | + // 130 hex digits | ||
| 29 | + let obj5 = {0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn: 1}; | ||
| 30 | + assertEquals( | ||
| 31 | + 1, | ||
| 32 | + obj5["3432398830065304857490950399540696608634717650071652704697231729592771591698828026061279820330727277488648155695740429018560993999858321906287014145557528575"]); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments