Skip to content

Commit ffc29c1

Browse files
MylesBorinstargos
authored andcommittedJun 13, 2018
deps: patch V8 to 6.7.288.46
PR-URL: #21260 Refs: v8/v8@6.7.288.45...6.7.288.46 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ali Ijaz Sheikh <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
1 parent fb71337 commit ffc29c1

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed
 

‎deps/v8/include/v8-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 6
1212
#define V8_MINOR_VERSION 7
1313
#define V8_BUILD_NUMBER 288
14-
#define V8_PATCH_LEVEL 45
14+
#define V8_PATCH_LEVEL 46
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

‎deps/v8/src/code-stub-assembler.cc

+25
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,18 @@ TNode<Smi> CodeStubAssembler::SmiFromInt32(SloppyTNode<Int32T> value) {
534534
WordShl(value_intptr, SmiShiftBitsConstant()));
535535
}
536536

537+
TNode<BoolT> CodeStubAssembler::IsValidPositiveSmi(TNode<IntPtrT> value) {
538+
intptr_t constant_value;
539+
if (ToIntPtrConstant(value, constant_value)) {
540+
return (static_cast<uintptr_t>(constant_value) <=
541+
static_cast<uintptr_t>(Smi::kMaxValue))
542+
? Int32TrueConstant()
543+
: Int32FalseConstant();
544+
}
545+
546+
return UintPtrLessThanOrEqual(value, IntPtrConstant(Smi::kMaxValue));
547+
}
548+
537549
TNode<Smi> CodeStubAssembler::SmiTag(SloppyTNode<IntPtrT> value) {
538550
int32_t constant_value;
539551
if (ToInt32Constant(value, constant_value) && Smi::IsValid(constant_value)) {
@@ -1002,6 +1014,19 @@ void CodeStubAssembler::GotoIfForceSlowPath(Label* if_true) {
10021014

10031015
Node* CodeStubAssembler::AllocateRaw(Node* size_in_bytes, AllocationFlags flags,
10041016
Node* top_address, Node* limit_address) {
1017+
// TODO(jgruber, chromium:848672): TNodeify AllocateRaw.
1018+
// TODO(jgruber, chromium:848672): Call FatalProcessOutOfMemory if this fails.
1019+
{
1020+
intptr_t constant_value;
1021+
if (ToIntPtrConstant(size_in_bytes, constant_value)) {
1022+
CHECK(Internals::IsValidSmi(constant_value));
1023+
CHECK_GT(constant_value, 0);
1024+
} else {
1025+
CSA_CHECK(this,
1026+
IsValidPositiveSmi(UncheckedCast<IntPtrT>(size_in_bytes)));
1027+
}
1028+
}
1029+
10051030
Node* top = Load(MachineType::Pointer(), top_address);
10061031
Node* limit = Load(MachineType::Pointer(), limit_address);
10071032

‎deps/v8/src/code-stub-assembler.h

+3
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
252252
TNode<Object> index,
253253
TNode<IntPtrT> length);
254254

255+
// Returns true iff the given value fits into smi range and is >= 0.
256+
TNode<BoolT> IsValidPositiveSmi(TNode<IntPtrT> value);
257+
255258
// Tag an IntPtr as a Smi value.
256259
TNode<Smi> SmiTag(SloppyTNode<IntPtrT> value);
257260
// Untag a Smi value as an IntPtr.

‎deps/v8/test/cctest/test-code-stub-assembler.cc

+43
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,49 @@ TEST(ToUint32) {
206206
ft.CheckThrows(factory->match_symbol());
207207
}
208208

209+
namespace {
210+
void IsValidPositiveSmiCase(Isolate* isolate, intptr_t value, bool expected) {
211+
const int kNumParams = 0;
212+
CodeAssemblerTester asm_tester(isolate, kNumParams);
213+
214+
CodeStubAssembler m(asm_tester.state());
215+
m.Return(
216+
m.SelectBooleanConstant(m.IsValidPositiveSmi(m.IntPtrConstant(value))));
217+
218+
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
219+
MaybeHandle<Object> maybe_handle = ft.Call();
220+
221+
if (expected) {
222+
CHECK(maybe_handle.ToHandleChecked()->IsTrue(isolate));
223+
} else {
224+
CHECK(maybe_handle.ToHandleChecked()->IsFalse(isolate));
225+
}
226+
}
227+
} // namespace
228+
229+
TEST(IsValidPositiveSmi) {
230+
Isolate* isolate(CcTest::InitIsolateOnce());
231+
232+
IsValidPositiveSmiCase(isolate, -1, false);
233+
IsValidPositiveSmiCase(isolate, 0, true);
234+
IsValidPositiveSmiCase(isolate, 1, true);
235+
236+
#ifdef V8_TARGET_ARCH_32_BIT
237+
IsValidPositiveSmiCase(isolate, 0x3FFFFFFFU, true);
238+
IsValidPositiveSmiCase(isolate, 0xC0000000U, false);
239+
IsValidPositiveSmiCase(isolate, 0x40000000U, false);
240+
IsValidPositiveSmiCase(isolate, 0xBFFFFFFFU, false);
241+
#else
242+
typedef std::numeric_limits<int32_t> int32_limits;
243+
IsValidPositiveSmiCase(isolate, int32_limits::max(), true);
244+
IsValidPositiveSmiCase(isolate, int32_limits::min(), false);
245+
IsValidPositiveSmiCase(isolate,
246+
static_cast<intptr_t>(int32_limits::max()) + 1, false);
247+
IsValidPositiveSmiCase(isolate,
248+
static_cast<intptr_t>(int32_limits::min()) - 1, false);
249+
#endif
250+
}
251+
209252
TEST(FixedArrayAccessSmiIndex) {
210253
Isolate* isolate(CcTest::InitIsolateOnce());
211254
CodeAssemblerTester asm_tester(isolate);

0 commit comments

Comments
 (0)
Please sign in to comment.