From 9deeec0b0882266cc6919cbdef3902bf0f85854e Mon Sep 17 00:00:00 2001 From: "whesse@chromium.org" Date: Fri, 23 Jul 2010 08:25:48 +0000 Subject: [PATCH] Change asserts to STATIC_ASSERT if they can be checked at compilation time. Just in the codegen-xxx.cc files on all platforms. Review URL: http://codereview.chromium.org/3017018 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5121 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/codegen-arm.cc | 156 +++++++++++++++---------------- src/ia32/codegen-ia32.cc | 196 ++++++++++++++++++++------------------- src/x64/codegen-x64.cc | 82 ++++++++-------- 3 files changed, 220 insertions(+), 214 deletions(-) diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc index a8e34b683b..bc76049cf4 100644 --- a/src/arm/codegen-arm.cc +++ b/src/arm/codegen-arm.cc @@ -815,7 +815,7 @@ void CodeGenerator::GenericBinaryOperation(Token::Value op, // Check they are both small and positive. __ tst(scratch, Operand(kSmiTagMask | 0xc0000000)); ASSERT(rhs.is(r0) || lhs.is(r0)); // r0 is free now. - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); if (op == Token::ADD) { __ add(r0, lhs, Operand(rhs), LeaveCC, eq); } else { @@ -863,7 +863,7 @@ void CodeGenerator::GenericBinaryOperation(Token::Value op, __ and_(r0, lhs, Operand(rhs), LeaveCC, cond); } else { ASSERT(op == Token::BIT_XOR); - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); __ eor(r0, lhs, Operand(rhs), LeaveCC, cond); } if (cond != al) { @@ -1520,8 +1520,8 @@ void CodeGenerator::CallApplyLazy(Expression* applicand, // JS_FUNCTION_TYPE is the last instance type and it is right // after LAST_JS_OBJECT_TYPE, we do not have to check the upper // bound. - ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); - ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); + STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); + STATIC_ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); __ CompareObjectType(receiver_reg, r2, r3, FIRST_JS_OBJECT_TYPE); __ b(lt, &build_args); @@ -2610,7 +2610,7 @@ void CodeGenerator::VisitTryCatchStatement(TryCatchStatement* node) { // The next handler address is on top of the frame. Unlink from // the handler list and drop the rest of this handler from the // frame. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); frame_->EmitPop(r1); __ mov(r3, Operand(handler_address)); __ str(r1, MemOperand(r3)); @@ -2636,7 +2636,7 @@ void CodeGenerator::VisitTryCatchStatement(TryCatchStatement* node) { __ ldr(sp, MemOperand(r3)); frame_->Forget(frame_->height() - handler_height); - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); frame_->EmitPop(r1); __ str(r1, MemOperand(r3)); frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); @@ -2723,7 +2723,7 @@ void CodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* node) { // chain and set the state on the frame to FALLING. if (has_valid_frame()) { // The next handler address is on top of the frame. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); frame_->EmitPop(r1); __ mov(r3, Operand(handler_address)); __ str(r1, MemOperand(r3)); @@ -2762,7 +2762,7 @@ void CodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* node) { // Unlink this handler and drop it from the frame. The next // handler address is currently on top of the frame. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); frame_->EmitPop(r1); __ str(r1, MemOperand(r3)); frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); @@ -4181,8 +4181,8 @@ void CodeGenerator::GenerateClassOf(ZoneList* args) { // As long as JS_FUNCTION_TYPE is the last instance type and it is // right after LAST_JS_OBJECT_TYPE, we can avoid checking for // LAST_JS_OBJECT_TYPE. - ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); - ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); + STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); + STATIC_ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); __ cmp(r1, Operand(JS_FUNCTION_TYPE)); function.Branch(eq); @@ -5128,7 +5128,7 @@ void CodeGenerator::GenerateGetFromCache(ZoneList* args) { const int kFingerOffset = FixedArray::OffsetOfElementAt(JSFunctionResultCache::kFingerIndex); - ASSERT(kSmiTag == 0 && kSmiTagSize == 1); + STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); __ ldr(r0, FieldMemOperand(r1, kFingerOffset)); // r0 now holds finger offset as a smi. __ add(r3, r1, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); @@ -6940,7 +6940,7 @@ void ConvertToDoubleStub::Generate(MacroAssembler* masm) { // Move sign bit from source to destination. This works because the sign bit // in the exponent word of the double has the same position and polarity as // the 2's complement sign bit in a Smi. - ASSERT(HeapNumber::kSignMask == 0x80000000u); + STATIC_ASSERT(HeapNumber::kSignMask == 0x80000000u); __ and_(exponent, source_, Operand(HeapNumber::kSignMask), SetCC); // Subtract from 0 if source was negative. __ rsb(source_, source_, Operand(0), LeaveCC, ne); @@ -6993,7 +6993,7 @@ void WriteInt32ToHeapNumberStub::Generate(MacroAssembler* masm) { // the_int_ has the answer which is a signed int32 but not a Smi. // We test for the special value that has a different exponent. This test // has the neat side effect of setting the flags according to the sign. - ASSERT(HeapNumber::kSignMask == 0x80000000u); + STATIC_ASSERT(HeapNumber::kSignMask == 0x80000000u); __ cmp(the_int_, Operand(0x80000000u)); __ b(eq, &max_negative_int); // Set up the correct exponent in scratch_. All non-Smi int32s have the same. @@ -7338,7 +7338,7 @@ static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, // If either operand is a JSObject or an oddball value, then they are // not equal since their pointers are different. // There is no test for undetectability in strict equality. - ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); + STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); Label first_non_object; // Get the type of the first operand into r2 and compare it with // FIRST_JS_OBJECT_TYPE. @@ -7364,8 +7364,8 @@ static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, // Now that we have the types we might as well check for symbol-symbol. // Ensure that no non-strings have the symbol bit set. - ASSERT(kNotStringTag + kIsSymbolMask > LAST_TYPE); - ASSERT(kSymbolTag != 0); + STATIC_ASSERT(LAST_TYPE < kNotStringTag + kIsSymbolMask); + STATIC_ASSERT(kSymbolTag != 0); __ and_(r2, r2, Operand(r3)); __ tst(r2, Operand(kIsSymbolMask)); __ b(ne, &return_not_equal); @@ -7416,7 +7416,7 @@ static void EmitCheckForSymbolsOrObjects(MacroAssembler* masm, // r2 is object type of rhs. // Ensure that no non-strings have the symbol bit set. Label object_test; - ASSERT(kSymbolTag != 0); + STATIC_ASSERT(kSymbolTag != 0); __ tst(r2, Operand(kIsNotStringMask)); __ b(ne, &object_test); __ tst(r2, Operand(kIsSymbolMask)); @@ -7487,7 +7487,7 @@ void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm, not_found, true); - ASSERT_EQ(8, kDoubleSize); + STATIC_ASSERT(8 == kDoubleSize); __ add(scratch1, object, Operand(HeapNumber::kValueOffset - kHeapObjectTag)); @@ -7586,7 +7586,7 @@ void CompareStub::Generate(MacroAssembler* masm) { // If either is a Smi (we know that not both are), then they can only // be strictly equal if the other is a HeapNumber. - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); ASSERT_EQ(0, Smi::FromInt(0)); __ and_(r2, lhs_, Operand(rhs_)); __ tst(r2, Operand(kSmiTagMask)); @@ -8589,7 +8589,7 @@ void GenericBinaryOpStub::Generate(MacroAssembler* masm) { Label not_smi; // Fast path. if (ShouldGenerateSmiCode()) { - ASSERT(kSmiTag == 0); // Adjust code below. + STATIC_ASSERT(kSmiTag == 0); // Adjust code below. __ tst(smi_test_reg, Operand(kSmiTagMask)); __ b(ne, ¬_smi); __ add(r0, r1, Operand(r0), SetCC); // Add y optimistically. @@ -8605,7 +8605,7 @@ void GenericBinaryOpStub::Generate(MacroAssembler* masm) { Label not_smi; // Fast path. if (ShouldGenerateSmiCode()) { - ASSERT(kSmiTag == 0); // Adjust code below. + STATIC_ASSERT(kSmiTag == 0); // Adjust code below. __ tst(smi_test_reg, Operand(kSmiTagMask)); __ b(ne, ¬_smi); if (lhs.is(r1)) { @@ -8627,7 +8627,7 @@ void GenericBinaryOpStub::Generate(MacroAssembler* masm) { case Token::MUL: { Label not_smi, slow; if (ShouldGenerateSmiCode()) { - ASSERT(kSmiTag == 0); // adjust code below + STATIC_ASSERT(kSmiTag == 0); // adjust code below __ tst(smi_test_reg, Operand(kSmiTagMask)); Register scratch2 = smi_test_reg; smi_test_reg = no_reg; @@ -8763,7 +8763,7 @@ void GenericBinaryOpStub::Generate(MacroAssembler* masm) { Label slow; Label not_power_of_2; ASSERT(!ShouldGenerateSmiCode()); - ASSERT(kSmiTag == 0); // Adjust code below. + STATIC_ASSERT(kSmiTag == 0); // Adjust code below. // Check for two positive smis. __ orr(smi_test_reg, lhs, Operand(rhs)); __ tst(smi_test_reg, Operand(0x80000000u | kSmiTagMask)); @@ -8823,7 +8823,7 @@ void GenericBinaryOpStub::Generate(MacroAssembler* masm) { case Token::SHR: case Token::SHL: { Label slow; - ASSERT(kSmiTag == 0); // adjust code below + STATIC_ASSERT(kSmiTag == 0); // adjust code below __ tst(smi_test_reg, Operand(kSmiTagMask)); __ b(ne, &slow); Register scratch2 = smi_test_reg; @@ -9137,17 +9137,17 @@ void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { // r0 holds the exception. // Adjust this code if not the case. - ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); // Drop the sp to the top of the handler. __ mov(r3, Operand(ExternalReference(Top::k_handler_address))); __ ldr(sp, MemOperand(r3)); // Restore the next handler and frame pointer, discard handler state. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); __ pop(r2); __ str(r2, MemOperand(r3)); - ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); __ ldm(ia_w, sp, r3.bit() | fp.bit()); // r3: discarded state. // Before returning we restore the context from the frame pointer if @@ -9163,7 +9163,7 @@ void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { __ mov(lr, Operand(pc)); } #endif - ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); __ pop(pc); } @@ -9171,7 +9171,7 @@ void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, UncatchableExceptionType type) { // Adjust this code if not the case. - ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); // Drop sp to the top stack handler. __ mov(r3, Operand(ExternalReference(Top::k_handler_address))); @@ -9192,7 +9192,7 @@ void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, __ bind(&done); // Set the top handler address to next handler past the current ENTRY handler. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); __ pop(r2); __ str(r2, MemOperand(r3)); @@ -9216,7 +9216,7 @@ void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, // lr // Discard handler state (r2 is not used) and restore frame pointer. - ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); __ ldm(ia_w, sp, r2.bit() | fp.bit()); // r2: discarded state. // Before returning we restore the context from the frame pointer if // not NULL. The frame pointer is NULL in the exception handler of a @@ -9231,7 +9231,7 @@ void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, __ mov(lr, Operand(pc)); } #endif - ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); __ pop(pc); } @@ -9326,7 +9326,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm, // check for failure result Label failure_returned; - ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); + STATIC_ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); // Lower 2 bits of r2 are 0 iff r0 has failure tag. __ add(r2, r0, Operand(1)); __ tst(r2, Operand(kFailureTagMask)); @@ -9341,7 +9341,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm, // check if we should retry or throw exception Label retry; __ bind(&failure_returned); - ASSERT(Failure::RETRY_AFTER_GC == 0); + STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); __ tst(r0, Operand(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); __ b(eq, &retry); @@ -9744,12 +9744,12 @@ void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { } // Setup the callee in-object property. - ASSERT(Heap::arguments_callee_index == 0); + STATIC_ASSERT(Heap::arguments_callee_index == 0); __ ldr(r3, MemOperand(sp, 2 * kPointerSize)); __ str(r3, FieldMemOperand(r0, JSObject::kHeaderSize)); // Get the length (smi tagged) and set that as an in-object property too. - ASSERT(Heap::arguments_length_index == 1); + STATIC_ASSERT(Heap::arguments_length_index == 1); __ ldr(r1, MemOperand(sp, 0 * kPointerSize)); __ str(r1, FieldMemOperand(r0, JSObject::kHeaderSize + kPointerSize)); @@ -9841,7 +9841,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // Check that the first argument is a JSRegExp object. __ ldr(r0, MemOperand(sp, kJSRegExpOffset)); - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); __ tst(r0, Operand(kSmiTagMask)); __ b(eq, &runtime); __ CompareObjectType(r0, r1, r1, JS_REGEXP_TYPE); @@ -9868,8 +9868,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); // Calculate number of capture registers (number_of_captures + 1) * 2. This // uses the asumption that smis are 2 * their untagged value. - ASSERT_EQ(0, kSmiTag); - ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize); + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); __ add(r2, r2, Operand(2)); // r2 was a smi. // Check that the static offsets vector buffer is large enough. __ cmp(r2, Operand(OffsetsVector::kStaticOffsetsVectorSize)); @@ -9930,7 +9930,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); // First check for flat string. __ tst(r0, Operand(kIsNotStringMask | kStringRepresentationMask)); - ASSERT_EQ(0, kStringTag | kSeqStringTag); + STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); __ b(eq, &seq_string); // subject: Subject string @@ -9940,8 +9940,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // string. In that case the subject string is just the first part of the cons // string. Also in this case the first part of the cons string is known to be // a sequential string or an external string. - ASSERT(kExternalStringTag !=0); - ASSERT_EQ(0, kConsStringTag & kExternalStringTag); + STATIC_ASSERT(kExternalStringTag !=0); + STATIC_ASSERT((kConsStringTag & kExternalStringTag) == 0); __ tst(r0, Operand(kIsNotStringMask | kExternalStringTag)); __ b(ne, &runtime); __ ldr(r0, FieldMemOperand(subject, ConsString::kSecondOffset)); @@ -9952,7 +9952,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); // Is first part a flat string? - ASSERT_EQ(0, kSeqStringTag); + STATIC_ASSERT(kSeqStringTag == 0); __ tst(r0, Operand(kStringRepresentationMask)); __ b(nz, &runtime); @@ -9960,8 +9960,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // subject: Subject string // regexp_data: RegExp data (FixedArray) // r0: Instance type of subject string - ASSERT_EQ(4, kAsciiStringTag); - ASSERT_EQ(0, kTwoByteStringTag); + STATIC_ASSERT(4 == kAsciiStringTag); + STATIC_ASSERT(kTwoByteStringTag == 0); // Find the code object based on the assumptions above. __ and_(r0, r0, Operand(kStringEncodingMask)); __ mov(r3, Operand(r0, ASR, 2), SetCC); @@ -10015,7 +10015,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // calculate the shift of the index (0 for ASCII and 1 for two byte). __ ldr(r0, FieldMemOperand(subject, String::kLengthOffset)); __ mov(r0, Operand(r0, ASR, kSmiTagSize)); - ASSERT_EQ(SeqAsciiString::kHeaderSize, SeqTwoByteString::kHeaderSize); + STATIC_ASSERT(SeqAsciiString::kHeaderSize == SeqTwoByteString::kHeaderSize); __ add(r9, subject, Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); __ eor(r3, r3, Operand(1)); // Argument 4 (r3): End of string data @@ -10070,8 +10070,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ ldr(r1, FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); // Calculate number of capture registers (number_of_captures + 1) * 2. - ASSERT_EQ(0, kSmiTag); - ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize); + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); __ add(r1, r1, Operand(2)); // r1 was a smi. // r1: number of capture registers @@ -10283,7 +10283,7 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { __ b(ls, index_out_of_range_); // We need special handling for non-flat strings. - ASSERT(kSeqStringTag == 0); + STATIC_ASSERT(kSeqStringTag == 0); __ tst(result_, Operand(kStringRepresentationMask)); __ b(eq, &flat_string); @@ -10305,13 +10305,13 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); // If the first cons component is also non-flat, then go to runtime. - ASSERT(kSeqStringTag == 0); + STATIC_ASSERT(kSeqStringTag == 0); __ tst(result_, Operand(kStringRepresentationMask)); __ b(nz, &call_runtime_); // Check for 1-byte or 2-byte string. __ bind(&flat_string); - ASSERT(kAsciiStringTag != 0); + STATIC_ASSERT(kAsciiStringTag != 0); __ tst(result_, Operand(kStringEncodingMask)); __ b(nz, &ascii_string); @@ -10319,7 +10319,7 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { // Load the 2-byte character code into the result register. We can // add without shifting since the smi tag size is the log2 of the // number of bytes in a two-byte character. - ASSERT(kSmiTag == 0 && kSmiTagSize == 1 && kSmiShiftSize == 0); + STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1 && kSmiShiftSize == 0); __ add(scratch_, object_, Operand(scratch_)); __ ldrh(result_, FieldMemOperand(scratch_, SeqTwoByteString::kHeaderSize)); __ jmp(&got_char_code); @@ -10396,8 +10396,8 @@ void StringCharCodeAtGenerator::GenerateSlow( void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) { // Fast case of Heap::LookupSingleCharacterStringFromCode. - ASSERT(kSmiTag == 0); - ASSERT(kSmiShiftSize == 0); + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiShiftSize == 0); ASSERT(IsPowerOf2(String::kMaxAsciiCharCode + 1)); __ tst(code_, Operand(kSmiTagMask | @@ -10406,7 +10406,7 @@ void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) { __ LoadRoot(result_, Heap::kSingleCharacterStringCacheRootIndex); // At this point code register contains smi tagged ascii char code. - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); __ add(result_, result_, Operand(code_, LSL, kPointerSizeLog2 - kSmiTagSize)); __ ldr(result_, FieldMemOperand(result_, FixedArray::kHeaderSize)); __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); @@ -10511,7 +10511,7 @@ void StringHelper::GenerateCopyCharactersLong(MacroAssembler* masm, // Ensure that reading an entire aligned word containing the last character // of a string will not read outside the allocated area (because we pad up // to kObjectAlignment). - ASSERT(kObjectAlignment >= kReadAlignment); + STATIC_ASSERT(kObjectAlignment >= kReadAlignment); // Assumes word reads and writes are little endian. // Nothing to do for zero characters. Label done; @@ -10715,7 +10715,7 @@ void StringHelper::GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm, __ and_(candidate, candidate, Operand(mask)); // Load the entry from the symble table. - ASSERT_EQ(1, SymbolTable::kEntrySize); + STATIC_ASSERT(SymbolTable::kEntrySize == 1); __ ldr(candidate, MemOperand(first_symbol_table_element, candidate, @@ -10815,8 +10815,8 @@ void SubStringStub::Generate(MacroAssembler* masm) { // Check bounds and smi-ness. __ ldr(r7, MemOperand(sp, kToOffset)); __ ldr(r6, MemOperand(sp, kFromOffset)); - ASSERT_EQ(0, kSmiTag); - ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize); + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); // I.e., arithmetic shift right by one un-smi-tags. __ mov(r2, Operand(r7, ASR, 1), SetCC); __ mov(r3, Operand(r6, ASR, 1), SetCC, cc); @@ -10839,7 +10839,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { // Make sure first argument is a sequential (or flat) string. __ ldr(r5, MemOperand(sp, kStringOffset)); - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); __ tst(r5, Operand(kSmiTagMask)); __ b(eq, &runtime); Condition is_string = masm->IsObjectStringType(r5, r1); @@ -10853,8 +10853,8 @@ void SubStringStub::Generate(MacroAssembler* masm) { // r7: to (smi) Label seq_string; __ and_(r4, r1, Operand(kStringRepresentationMask)); - ASSERT(kSeqStringTag < kConsStringTag); - ASSERT(kExternalStringTag > kConsStringTag); + STATIC_ASSERT(kSeqStringTag < kConsStringTag); + STATIC_ASSERT(kConsStringTag < kExternalStringTag); __ cmp(r4, Operand(kConsStringTag)); __ b(gt, &runtime); // External strings go to runtime. __ b(lt, &seq_string); // Sequential strings are handled directly. @@ -10866,7 +10866,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { __ ldr(r4, FieldMemOperand(r5, HeapObject::kMapOffset)); __ ldrb(r1, FieldMemOperand(r4, Map::kInstanceTypeOffset)); __ tst(r1, Operand(kStringRepresentationMask)); - ASSERT_EQ(0, kSeqStringTag); + STATIC_ASSERT(kSeqStringTag == 0); __ b(ne, &runtime); // Cons and External strings go to runtime. // Definitly a sequential string. @@ -10890,7 +10890,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { // Check for flat ascii string. Label non_ascii_flat; __ tst(r1, Operand(kStringEncodingMask)); - ASSERT_EQ(0, kTwoByteStringTag); + STATIC_ASSERT(kTwoByteStringTag == 0); __ b(eq, &non_ascii_flat); Label result_longer_than_two; @@ -10939,7 +10939,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { // r1: first character of result string. // r2: result string length. // r5: first character of sub string to copy. - ASSERT_EQ(0, SeqAsciiString::kHeaderSize & kObjectAlignmentMask); + STATIC_ASSERT((SeqAsciiString::kHeaderSize & kObjectAlignmentMask) == 0); StringHelper::GenerateCopyCharactersLong(masm, r1, r5, r2, r3, r4, r6, r7, r9, COPY_ASCII | DEST_ALWAYS_ALIGNED); __ IncrementCounter(&Counters::sub_string_native, 1, r3, r4); @@ -10970,7 +10970,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { // r1: first character of result. // r2: result length. // r5: first character of string to copy. - ASSERT_EQ(0, SeqTwoByteString::kHeaderSize & kObjectAlignmentMask); + STATIC_ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); StringHelper::GenerateCopyCharactersLong(masm, r1, r5, r2, r3, r4, r6, r7, r9, DEST_ALWAYS_ALIGNED); __ IncrementCounter(&Counters::sub_string_native, 1, r3, r4); @@ -10998,7 +10998,7 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, Register length_delta = scratch3; __ mov(scratch1, scratch2, LeaveCC, gt); Register min_length = scratch1; - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); __ tst(min_length, Operand(min_length)); __ b(eq, &compare_lengths); @@ -11054,8 +11054,8 @@ void StringCompareStub::Generate(MacroAssembler* masm) { Label not_same; __ cmp(r0, r1); __ b(ne, ¬_same); - ASSERT_EQ(0, EQUAL); - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(EQUAL == 0); + STATIC_ASSERT(kSmiTag == 0); __ mov(r0, Operand(Smi::FromInt(EQUAL))); __ IncrementCounter(&Counters::string_compare_native, 1, r1, r2); __ add(sp, sp, Operand(2 * kPointerSize)); @@ -11090,14 +11090,14 @@ void StringAddStub::Generate(MacroAssembler* masm) { // Make sure that both arguments are strings if not known in advance. if (string_check_) { - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); __ JumpIfEitherSmi(r0, r1, &string_add_runtime); // Load instance types. __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset)); __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset)); __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); - ASSERT_EQ(0, kStringTag); + STATIC_ASSERT(kStringTag == 0); // If either is not a string, go to runtime. __ tst(r4, Operand(kIsNotStringMask)); __ tst(r5, Operand(kIsNotStringMask), eq); @@ -11114,10 +11114,10 @@ void StringAddStub::Generate(MacroAssembler* masm) { // Check if either of the strings are empty. In that case return the other. __ ldr(r2, FieldMemOperand(r0, String::kLengthOffset)); __ ldr(r3, FieldMemOperand(r1, String::kLengthOffset)); - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); __ cmp(r2, Operand(Smi::FromInt(0))); // Test if first string is empty. __ mov(r0, Operand(r1), LeaveCC, eq); // If first is empty, return second. - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); // Else test if second string is empty. __ cmp(r3, Operand(Smi::FromInt(0)), ne); __ b(ne, &strings_not_empty); // If either string was empty, return r0. @@ -11141,7 +11141,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { // Look at the length of the result of adding the two strings. Label string_add_flat_result, longer_than_two; // Adding two lengths can't overflow. - ASSERT(String::kMaxLength * 2 > String::kMaxLength); + STATIC_ASSERT(String::kMaxLength < String::kMaxLength * 2); __ add(r6, r2, Operand(r3)); // Use the runtime system when adding two one character strings, as it // contains optimizations for this specific case using the symbol table. @@ -11189,7 +11189,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { __ cmp(r6, Operand(String::kMinNonFlatLength)); __ b(lt, &string_add_flat_result); // Handle exceptionally long strings in the runtime system. - ASSERT((String::kMaxLength & 0x80000000) == 0); + STATIC_ASSERT((String::kMaxLength & 0x80000000) == 0); ASSERT(IsPowerOf2(String::kMaxLength + 1)); // kMaxLength + 1 is representable as shifted literal, kMaxLength is not. __ cmp(r6, Operand(String::kMaxLength + 1)); @@ -11204,7 +11204,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); } Label non_ascii, allocated, ascii_data; - ASSERT_EQ(0, kTwoByteStringTag); + STATIC_ASSERT(kTwoByteStringTag == 0); __ tst(r4, Operand(kStringEncodingMask)); __ tst(r5, Operand(kStringEncodingMask), ne); __ b(eq, &non_ascii); @@ -11230,7 +11230,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { __ tst(r5, Operand(kAsciiDataHintMask), ne); __ b(ne, &ascii_data); __ eor(r4, r4, Operand(r5)); - ASSERT(kAsciiStringTag != 0 && kAsciiDataHintTag != 0); + STATIC_ASSERT(kAsciiStringTag != 0 && kAsciiDataHintTag != 0); __ and_(r4, r4, Operand(kAsciiStringTag | kAsciiDataHintTag)); __ cmp(r4, Operand(kAsciiStringTag | kAsciiDataHintTag)); __ b(eq, &ascii_data); @@ -11256,7 +11256,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); } // Check that both strings are sequential. - ASSERT_EQ(0, kSeqStringTag); + STATIC_ASSERT(kSeqStringTag == 0); __ tst(r4, Operand(kStringRepresentationMask)); __ tst(r5, Operand(kStringRepresentationMask), eq); __ b(ne, &string_add_runtime); diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index 1187d29496..d4927e3e29 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -905,7 +905,7 @@ void CodeGenerator::ToBoolean(ControlDestination* dest) { __ AbortIfNotNumber(value.reg()); } // Smi => false iff zero. - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); __ test(value.reg(), Operand(value.reg())); dest->false_target()->Branch(zero); __ test(value.reg(), Immediate(kSmiTagMask)); @@ -930,7 +930,7 @@ void CodeGenerator::ToBoolean(ControlDestination* dest) { dest->false_target()->Branch(equal); // Smi => false iff zero. - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); __ test(value.reg(), Operand(value.reg())); dest->false_target()->Branch(zero); __ test(value.reg(), Immediate(kSmiTagMask)); @@ -1169,7 +1169,7 @@ static TypeInfo CalculateTypeInfo(TypeInfo operands_type, const Result& left) { // Set TypeInfo of result according to the operation performed. // Rely on the fact that smis have a 31 bit payload on ia32. - ASSERT(kSmiValueSize == 31); + STATIC_ASSERT(kSmiValueSize == 31); switch (op) { case Token::COMMA: return right.type_info(); @@ -1599,7 +1599,7 @@ Result CodeGenerator::LikelySmiBinaryOperation(BinaryOperation* expr, // Check for the corner case of dividing the most negative smi by // -1. We cannot use the overflow flag, since it is not set by // idiv instruction. - ASSERT(kSmiTag == 0 && kSmiTagSize == 1); + STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); __ cmp(eax, 0x40000000); deferred->Branch(equal); // Check that the remainder is zero. @@ -1789,7 +1789,7 @@ Result CodeGenerator::LikelySmiBinaryOperation(BinaryOperation* expr, case Token::MUL: { // If the smi tag is 0 we can just leave the tag on one operand. - ASSERT(kSmiTag == 0); // Adjust code below if not the case. + STATIC_ASSERT(kSmiTag == 0); // Adjust code below if not the case. // Remove smi tag from the left operand (but keep sign). // Left-hand operand has been copied into answer. __ SmiUntag(answer.reg()); @@ -2296,13 +2296,13 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, __ AbortIfNotSmi(operand->reg()); } __ mov(answer.reg(), operand->reg()); - ASSERT(kSmiTag == 0); // adjust code if not the case + STATIC_ASSERT(kSmiTag == 0); // adjust code if not the case // We do no shifts, only the Smi conversion, if shift_value is 1. if (shift_value > 1) { __ shl(answer.reg(), shift_value - 1); } // Convert int result to Smi, checking that it is in int range. - ASSERT(kSmiTagSize == 1); // adjust code if not the case + STATIC_ASSERT(kSmiTagSize == 1); // adjust code if not the case __ add(answer.reg(), Operand(answer.reg())); deferred->Branch(overflow); deferred->BindExit(); @@ -2370,8 +2370,8 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, overwrite_mode); // Check that lowest log2(value) bits of operand are zero, and test // smi tag at the same time. - ASSERT_EQ(0, kSmiTag); - ASSERT_EQ(1, kSmiTagSize); + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTagSize == 1); __ test(operand->reg(), Immediate(3)); deferred->Branch(not_zero); // Branch if non-smi or odd smi. __ sar(operand->reg(), 1); @@ -2605,9 +2605,9 @@ void CodeGenerator::Comparison(AstNode* node, // side (which is always a symbol). if (cc == equal) { Label not_a_symbol; - ASSERT(kSymbolTag != 0); + STATIC_ASSERT(kSymbolTag != 0); // Ensure that no non-strings have the symbol bit set. - ASSERT(kNotStringTag + kIsSymbolMask > LAST_TYPE); + STATIC_ASSERT(LAST_TYPE < kNotStringTag + kIsSymbolMask); __ test(temp.reg(), Immediate(kIsSymbolMask)); // Test the symbol bit. __ j(zero, ¬_a_symbol); // They are symbols, so do identity compare. @@ -3151,8 +3151,8 @@ void CodeGenerator::CallApplyLazy(Expression* applicand, // JS_FUNCTION_TYPE is the last instance type and it is right // after LAST_JS_OBJECT_TYPE, we do not have to check the upper // bound. - ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); - ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); + STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); + STATIC_ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, ecx); __ j(below, &build_args); @@ -4476,7 +4476,7 @@ void CodeGenerator::VisitTryCatchStatement(TryCatchStatement* node) { // The next handler address is on top of the frame. Unlink from // the handler list and drop the rest of this handler from the // frame. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); frame_->EmitPop(Operand::StaticVariable(handler_address)); frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); if (has_unlinks) { @@ -4507,7 +4507,7 @@ void CodeGenerator::VisitTryCatchStatement(TryCatchStatement* node) { __ mov(esp, Operand::StaticVariable(handler_address)); frame_->Forget(frame_->height() - handler_height); - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); frame_->EmitPop(Operand::StaticVariable(handler_address)); frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); @@ -4593,7 +4593,7 @@ void CodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* node) { // chain and set the state on the frame to FALLING. if (has_valid_frame()) { // The next handler address is on top of the frame. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); frame_->EmitPop(Operand::StaticVariable(handler_address)); frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); @@ -4632,7 +4632,7 @@ void CodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* node) { frame_->Forget(frame_->height() - handler_height); // Unlink this handler and drop it from the frame. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); frame_->EmitPop(Operand::StaticVariable(handler_address)); frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); @@ -6573,8 +6573,8 @@ void CodeGenerator::GenerateClassOf(ZoneList* args) { // As long as JS_FUNCTION_TYPE is the last instance type and it is // right after LAST_JS_OBJECT_TYPE, we can avoid checking for // LAST_JS_OBJECT_TYPE. - ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); - ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); + STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); + STATIC_ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); __ CmpInstanceType(obj.reg(), JS_FUNCTION_TYPE); function.Branch(equal); @@ -6715,7 +6715,7 @@ void CodeGenerator::GenerateObjectEquals(ZoneList* args) { void CodeGenerator::GenerateGetFramePointer(ZoneList* args) { ASSERT(args->length() == 0); - ASSERT(kSmiTag == 0); // EBP value is aligned, so it should look like Smi. + STATIC_ASSERT(kSmiTag == 0); // EBP value is aligned, so it looks like a Smi. Result ebp_as_smi = allocator_->Allocate(); ASSERT(ebp_as_smi.is_valid()); __ mov(ebp_as_smi.reg(), Operand(ebp)); @@ -7069,7 +7069,7 @@ void CodeGenerator::GenerateGetFromCache(ZoneList* args) { key.reg()); // tmp.reg() now holds finger offset as a smi. - ASSERT(kSmiTag == 0 && kSmiTagSize == 1); + STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); __ mov(tmp.reg(), FieldOperand(cache.reg(), JSFunctionResultCache::kFingerOffset)); __ cmp(key.reg(), FixedArrayElementOperand(cache.reg(), tmp.reg())); @@ -9031,7 +9031,7 @@ Result CodeGenerator::EmitKeyedLoad() { // Load and check that the result is not the hole. // Key holds a smi. - ASSERT((kSmiTag == 0) && (kSmiTagSize == 1)); + STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); __ mov(elements.reg(), FieldOperand(elements.reg(), key.reg(), @@ -9407,7 +9407,9 @@ void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { Label slow_case; __ mov(ecx, Operand(esp, 3 * kPointerSize)); __ mov(eax, Operand(esp, 2 * kPointerSize)); - ASSERT((kPointerSize == 4) && (kSmiTagSize == 1) && (kSmiTag == 0)); + STATIC_ASSERT(kPointerSize == 4); + STATIC_ASSERT(kSmiTagSize == 1); + STATIC_ASSERT(kSmiTag == 0); __ mov(ecx, CodeGenerator::FixedArrayElementOperand(ecx, eax)); __ cmp(ecx, Factory::undefined_value()); __ j(equal, &slow_case); @@ -9471,7 +9473,7 @@ void ToBooleanStub::Generate(MacroAssembler* masm) { // String value => false iff empty. __ CmpInstanceType(edx, FIRST_NONSTRING_TYPE); __ j(above_equal, ¬_string); - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); __ cmp(FieldOperand(eax, String::kLengthOffset), Immediate(0)); __ j(zero, &false_result); __ jmp(&true_result); @@ -9721,7 +9723,7 @@ void GenericBinaryOpStub::GenerateSmiCode(MacroAssembler* masm, Label* slow) { } // 3. Perform the smi check of the operands. - ASSERT(kSmiTag == 0); // Adjust zero check if not the case. + STATIC_ASSERT(kSmiTag == 0); // Adjust zero check if not the case. __ test(combined, Immediate(kSmiTagMask)); __ j(not_zero, ¬_smis, not_taken); @@ -9802,7 +9804,7 @@ void GenericBinaryOpStub::GenerateSmiCode(MacroAssembler* masm, Label* slow) { case Token::MUL: // If the smi tag is 0 we can just leave the tag on one operand. - ASSERT(kSmiTag == 0); // Adjust code below if not the case. + STATIC_ASSERT(kSmiTag == 0); // Adjust code below if not the case. // We can't revert the multiplication if the result is not a smi // so save the right operand. __ mov(ebx, right); @@ -9830,7 +9832,7 @@ void GenericBinaryOpStub::GenerateSmiCode(MacroAssembler* masm, Label* slow) { // Check for the corner case of dividing the most negative smi by // -1. We cannot use the overflow flag, since it is not set by idiv // instruction. - ASSERT(kSmiTag == 0 && kSmiTagSize == 1); + STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); __ cmp(eax, 0x40000000); __ j(equal, &use_fp_on_smis); // Check for negative zero result. Use combined = left | right. @@ -10403,7 +10405,7 @@ void TranscendentalCacheStub::Generate(MacroAssembler* masm) { __ j(not_zero, &input_not_smi); // Input is a smi. Untag and load it onto the FPU stack. // Then load the low and high words of the double into ebx, edx. - ASSERT_EQ(1, kSmiTagSize); + STATIC_ASSERT(kSmiTagSize == 1); __ sar(eax, 1); __ sub(Operand(esp), Immediate(2 * kPointerSize)); __ mov(Operand(esp, 0), eax); @@ -11122,7 +11124,7 @@ void GenericUnaryOpStub::Generate(MacroAssembler* masm) { __ j(sign, &try_float, not_taken); // Tag the result as a smi and we're done. - ASSERT(kSmiTagSize == 1); + STATIC_ASSERT(kSmiTagSize == 1); __ lea(eax, Operand(ecx, times_2, kSmiTag)); __ jmp(&done); @@ -11198,7 +11200,8 @@ void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { __ j(above_equal, &slow, not_taken); // Read the argument from the stack and return it. - ASSERT(kSmiTagSize == 1 && kSmiTag == 0); // shifting code depends on this + STATIC_ASSERT(kSmiTagSize == 1); + STATIC_ASSERT(kSmiTag == 0); // Shifting code depends on these. __ lea(ebx, Operand(ebp, eax, times_2, 0)); __ neg(edx); __ mov(eax, Operand(ebx, edx, times_2, kDisplacement)); @@ -11213,7 +11216,8 @@ void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { __ j(above_equal, &slow, not_taken); // Read the argument from the stack and return it. - ASSERT(kSmiTagSize == 1 && kSmiTag == 0); // shifting code depends on this + STATIC_ASSERT(kSmiTagSize == 1); + STATIC_ASSERT(kSmiTag == 0); // Shifting code depends on these. __ lea(ebx, Operand(ebx, ecx, times_2, 0)); __ neg(edx); __ mov(eax, Operand(ebx, edx, times_2, kDisplacement)); @@ -11284,12 +11288,12 @@ void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { } // Setup the callee in-object property. - ASSERT(Heap::arguments_callee_index == 0); + STATIC_ASSERT(Heap::arguments_callee_index == 0); __ mov(ebx, Operand(esp, 3 * kPointerSize)); __ mov(FieldOperand(eax, JSObject::kHeaderSize), ebx); // Get the length (smi tagged) and set that as an in-object property too. - ASSERT(Heap::arguments_length_index == 1); + STATIC_ASSERT(Heap::arguments_length_index == 1); __ mov(ecx, Operand(esp, 1 * kPointerSize)); __ mov(FieldOperand(eax, JSObject::kHeaderSize + kPointerSize), ecx); @@ -11368,7 +11372,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // Check that the first argument is a JSRegExp object. __ mov(eax, Operand(esp, kJSRegExpOffset)); - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); __ test(eax, Immediate(kSmiTagMask)); __ j(zero, &runtime); __ CmpObjectType(eax, JS_REGEXP_TYPE, ecx); @@ -11393,8 +11397,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ mov(edx, FieldOperand(ecx, JSRegExp::kIrregexpCaptureCountOffset)); // Calculate number of capture registers (number_of_captures + 1) * 2. This // uses the asumption that smis are 2 * their untagged value. - ASSERT_EQ(0, kSmiTag); - ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize); + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); __ add(Operand(edx), Immediate(2)); // edx was a smi. // Check that the static offsets vector buffer is large enough. __ cmp(edx, OffsetsVector::kStaticOffsetsVectorSize); @@ -11452,7 +11456,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // First check for flat two byte string. __ and_(ebx, kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask); - ASSERT_EQ(0, kStringTag | kSeqStringTag | kTwoByteStringTag); + STATIC_ASSERT((kStringTag | kSeqStringTag | kTwoByteStringTag) == 0); __ j(zero, &seq_two_byte_string); // Any other flat string must be a flat ascii string. __ test(Operand(ebx), @@ -11464,8 +11468,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // string. In that case the subject string is just the first part of the cons // string. Also in this case the first part of the cons string is known to be // a sequential string or an external string. - ASSERT(kExternalStringTag !=0); - ASSERT_EQ(0, kConsStringTag & kExternalStringTag); + STATIC_ASSERT(kExternalStringTag != 0); + STATIC_ASSERT((kConsStringTag & kExternalStringTag) == 0); __ test(Operand(ebx), Immediate(kIsNotStringMask | kExternalStringTag)); __ j(not_zero, &runtime); @@ -11481,7 +11485,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // Is first part a flat two byte string? __ test_b(FieldOperand(ebx, Map::kInstanceTypeOffset), kStringRepresentationMask | kStringEncodingMask); - ASSERT_EQ(0, kSeqStringTag | kTwoByteStringTag); + STATIC_ASSERT((kSeqStringTag | kTwoByteStringTag) == 0); __ j(zero, &seq_two_byte_string); // Any other flat string must be ascii. __ test_b(FieldOperand(ebx, Map::kInstanceTypeOffset), @@ -11552,7 +11556,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ jmp(&setup_rest); __ bind(&setup_two_byte); - ASSERT(kSmiTag == 0 && kSmiTagSize == 1); // edi is smi (powered by 2). + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTagSize == 1); // edi is smi (powered by 2). __ lea(ecx, FieldOperand(eax, edi, times_1, SeqTwoByteString::kHeaderSize)); __ mov(Operand(esp, 3 * kPointerSize), ecx); // Argument 4. __ lea(ecx, FieldOperand(eax, ebx, times_2, SeqTwoByteString::kHeaderSize)); @@ -11600,8 +11605,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset)); __ mov(edx, FieldOperand(ecx, JSRegExp::kIrregexpCaptureCountOffset)); // Calculate number of capture registers (number_of_captures + 1) * 2. - ASSERT_EQ(0, kSmiTag); - ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize); + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); __ add(Operand(edx), Immediate(2)); // edx was a smi. // edx: Number of capture registers @@ -11696,7 +11701,7 @@ void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm, __ SmiUntag(scratch); } else { Label not_smi, hash_calculated; - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); __ test(object, Immediate(kSmiTagMask)); __ j(not_zero, ¬_smi); __ mov(scratch, object); @@ -11706,7 +11711,7 @@ void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm, __ cmp(FieldOperand(object, HeapObject::kMapOffset), Factory::heap_number_map()); __ j(not_equal, not_found); - ASSERT_EQ(8, kDoubleSize); + STATIC_ASSERT(8 == kDoubleSize); __ mov(scratch, FieldOperand(object, HeapNumber::kValueOffset)); __ xor_(scratch, FieldOperand(object, HeapNumber::kValueOffset + 4)); // Object is heap number and hash is now in scratch. Calculate cache index. @@ -11837,7 +11842,7 @@ void CompareStub::Generate(MacroAssembler* masm) { // Value is a QNaN if value & kQuietNaNMask == kQuietNaNMask, i.e., // all bits in the mask are set. We only need to check the word // that contains the exponent and high bit of the mantissa. - ASSERT_NE(0, (kQuietNaNHighBitsMask << 1) & 0x80000000u); + STATIC_ASSERT(((kQuietNaNHighBitsMask << 1) & 0x80000000u) != 0); __ mov(edx, FieldOperand(edx, HeapNumber::kExponentOffset)); __ xor_(eax, Operand(eax)); // Shift value and mask so kQuietNaNHighBitsMask applies to topmost @@ -11845,7 +11850,7 @@ void CompareStub::Generate(MacroAssembler* masm) { __ add(edx, Operand(edx)); __ cmp(edx, kQuietNaNHighBitsMask << 1); if (cc_ == equal) { - ASSERT_NE(1, EQUAL); + STATIC_ASSERT(EQUAL != 1); __ setcc(above_equal, eax); __ ret(0); } else { @@ -11873,7 +11878,7 @@ void CompareStub::Generate(MacroAssembler* masm) { // slow-case code. // If either is a Smi (we know that not both are), then they can only // be equal if the other is a HeapNumber. If so, use the slow case. - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); ASSERT_EQ(0, Smi::FromInt(0)); __ mov(ecx, Immediate(kSmiTagMask)); __ and_(ecx, Operand(eax)); @@ -11882,7 +11887,7 @@ void CompareStub::Generate(MacroAssembler* masm) { // One operand is a smi. // Check whether the non-smi is a heap number. - ASSERT_EQ(1, kSmiTagMask); + STATIC_ASSERT(kSmiTagMask == 1); // ecx still holds eax & kSmiTag, which is either zero or one. __ sub(Operand(ecx), Immediate(0x01)); __ mov(ebx, edx); @@ -11908,13 +11913,13 @@ void CompareStub::Generate(MacroAssembler* masm) { // Get the type of the first operand. // If the first object is a JS object, we have done pointer comparison. Label first_non_object; - ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); + STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, ecx); __ j(below, &first_non_object); // Return non-zero (eax is not zero) Label return_not_equal; - ASSERT(kHeapObjectTag != 0); + STATIC_ASSERT(kHeapObjectTag != 0); __ bind(&return_not_equal); __ ret(0); @@ -12034,8 +12039,8 @@ void CompareStub::Generate(MacroAssembler* masm) { // At most one is a smi, so we can test for smi by adding the two. // A smi plus a heap object has the low bit set, a heap object plus // a heap object has the low bit clear. - ASSERT_EQ(0, kSmiTag); - ASSERT_EQ(1, kSmiTagMask); + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTagMask == 1); __ lea(ecx, Operand(eax, edx, times_1, 0)); __ test(ecx, Immediate(kSmiTagMask)); __ j(not_zero, ¬_both_objects); @@ -12175,16 +12180,16 @@ void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { // eax holds the exception. // Adjust this code if not the case. - ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); // Drop the sp to the top of the handler. ExternalReference handler_address(Top::k_handler_address); __ mov(esp, Operand::StaticVariable(handler_address)); // Restore next handler and frame pointer, discard handler state. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); __ pop(Operand::StaticVariable(handler_address)); - ASSERT(StackHandlerConstants::kFPOffset == 1 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kFPOffset == 1 * kPointerSize); __ pop(ebp); __ pop(edx); // Remove state. @@ -12198,7 +12203,7 @@ void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); __ bind(&skip); - ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); __ ret(0); } @@ -12218,7 +12223,7 @@ void ApiGetterEntryStub::Generate(MacroAssembler* masm) { Label prologue; Label promote_scheduled_exception; __ EnterApiExitFrame(ExitFrame::MODE_NORMAL, kStackSpace, kArgc); - ASSERT_EQ(kArgc, 4); + STATIC_ASSERT(kArgc == 4); if (kPassHandlesDirectly) { // When handles as passed directly we don't have to allocate extra // space for and pass an out parameter. @@ -12333,7 +12338,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm, // Check for failure result. Label failure_returned; - ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); + STATIC_ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); __ lea(ecx, Operand(eax, 1)); // Lower 2 bits of ecx are 0 iff eax has failure tag. __ test(ecx, Immediate(kFailureTagMask)); @@ -12348,7 +12353,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm, Label retry; // If the returned exception is RETRY_AFTER_GC continue at retry label - ASSERT(Failure::RETRY_AFTER_GC == 0); + STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); __ test(eax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); __ j(zero, &retry, taken); @@ -12379,7 +12384,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm, void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, UncatchableExceptionType type) { // Adjust this code if not the case. - ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); // Drop sp to the top stack handler. ExternalReference handler_address(Top::k_handler_address); @@ -12399,7 +12404,7 @@ void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, __ bind(&done); // Set the top handler address to next handler past the current ENTRY handler. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); __ pop(Operand::StaticVariable(handler_address)); if (type == OUT_OF_MEMORY) { @@ -12418,11 +12423,11 @@ void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, __ xor_(esi, Operand(esi)); // Restore fp from handler and discard handler state. - ASSERT(StackHandlerConstants::kFPOffset == 1 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kFPOffset == 1 * kPointerSize); __ pop(ebp); __ pop(edx); // State. - ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); __ ret(0); } @@ -12733,7 +12738,7 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { Label got_char_code; // If the receiver is a smi trigger the non-string case. - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); __ test(object_, Immediate(kSmiTagMask)); __ j(zero, receiver_not_string_); @@ -12745,7 +12750,7 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { __ j(not_zero, receiver_not_string_); // If the index is non-smi trigger the non-smi case. - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); __ test(index_, Immediate(kSmiTagMask)); __ j(not_zero, &index_not_smi_); @@ -12758,7 +12763,7 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { __ j(above_equal, index_out_of_range_); // We need special handling for non-flat strings. - ASSERT(kSeqStringTag == 0); + STATIC_ASSERT(kSeqStringTag == 0); __ test(result_, Immediate(kStringRepresentationMask)); __ j(zero, &flat_string); @@ -12779,19 +12784,19 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { __ mov(result_, FieldOperand(object_, HeapObject::kMapOffset)); __ movzx_b(result_, FieldOperand(result_, Map::kInstanceTypeOffset)); // If the first cons component is also non-flat, then go to runtime. - ASSERT(kSeqStringTag == 0); + STATIC_ASSERT(kSeqStringTag == 0); __ test(result_, Immediate(kStringRepresentationMask)); __ j(not_zero, &call_runtime_); // Check for 1-byte or 2-byte string. __ bind(&flat_string); - ASSERT(kAsciiStringTag != 0); + STATIC_ASSERT(kAsciiStringTag != 0); __ test(result_, Immediate(kStringEncodingMask)); __ j(not_zero, &ascii_string); // 2-byte string. // Load the 2-byte character code into the result register. - ASSERT(kSmiTag == 0 && kSmiTagSize == 1); + STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); __ movzx_w(result_, FieldOperand(object_, scratch_, times_1, // Scratch is smi-tagged. SeqTwoByteString::kHeaderSize)); @@ -12841,7 +12846,7 @@ void StringCharCodeAtGenerator::GenerateSlow( __ movzx_b(result_, FieldOperand(result_, Map::kInstanceTypeOffset)); call_helper.AfterCall(masm); // If index is still not a smi, it must be out of range. - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); __ test(scratch_, Immediate(kSmiTagMask)); __ j(not_zero, index_out_of_range_); // Otherwise, return to the fast path. @@ -12870,8 +12875,8 @@ void StringCharCodeAtGenerator::GenerateSlow( void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) { // Fast case of Heap::LookupSingleCharacterStringFromCode. - ASSERT(kSmiTag == 0); - ASSERT(kSmiShiftSize == 0); + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiShiftSize == 0); ASSERT(IsPowerOf2(String::kMaxAsciiCharCode + 1)); __ test(code_, Immediate(kSmiTagMask | @@ -12879,9 +12884,9 @@ void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) { __ j(not_zero, &slow_case_, not_taken); __ Set(result_, Immediate(Factory::single_character_string_cache())); - ASSERT(kSmiTag == 0); - ASSERT(kSmiTagSize == 1); - ASSERT(kSmiShiftSize == 0); + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTagSize == 1); + STATIC_ASSERT(kSmiShiftSize == 0); // At this point code register contains smi tagged ascii char code. __ mov(result_, FieldOperand(result_, code_, times_half_pointer_size, @@ -12953,7 +12958,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { // Check if either of the strings are empty. In that case return the other. Label second_not_zero_length, both_not_zero_length; __ mov(ecx, FieldOperand(edx, String::kLengthOffset)); - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); __ test(ecx, Operand(ecx)); __ j(not_zero, &second_not_zero_length); // Second string is empty, result is first string which is already in eax. @@ -12961,7 +12966,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { __ ret(2 * kPointerSize); __ bind(&second_not_zero_length); __ mov(ebx, FieldOperand(eax, String::kLengthOffset)); - ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTag == 0); __ test(ebx, Operand(ebx)); __ j(not_zero, &both_not_zero_length); // First string is empty, result is second string which is in edx. @@ -12978,7 +12983,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { Label string_add_flat_result, longer_than_two; __ bind(&both_not_zero_length); __ add(ebx, Operand(ecx)); - ASSERT(Smi::kMaxValue == String::kMaxLength); + STATIC_ASSERT(Smi::kMaxValue == String::kMaxLength); // Handle exceptionally long strings in the runtime system. __ j(overflow, &string_add_runtime); // Use the runtime system when adding two one character strings, as it @@ -13019,7 +13024,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); __ movzx_b(edi, FieldOperand(edi, Map::kInstanceTypeOffset)); __ and_(ecx, Operand(edi)); - ASSERT(kStringEncodingMask == kAsciiStringTag); + STATIC_ASSERT(kStringEncodingMask == kAsciiStringTag); __ test(ecx, Immediate(kAsciiStringTag)); __ j(zero, &non_ascii); __ bind(&ascii_data); @@ -13046,7 +13051,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); __ xor_(edi, Operand(ecx)); - ASSERT(kAsciiStringTag != 0 && kAsciiDataHintTag != 0); + STATIC_ASSERT(kAsciiStringTag != 0 && kAsciiDataHintTag != 0); __ and_(edi, kAsciiStringTag | kAsciiDataHintTag); __ cmp(edi, kAsciiStringTag | kAsciiDataHintTag); __ j(equal, &ascii_data); @@ -13075,7 +13080,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { // ebx: length of resulting flat string as a smi // edx: second string Label non_ascii_string_add_flat_result; - ASSERT(kStringEncodingMask == kAsciiStringTag); + STATIC_ASSERT(kStringEncodingMask == kAsciiStringTag); __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); __ test_b(FieldOperand(ecx, Map::kInstanceTypeOffset), kAsciiStringTag); __ j(zero, &non_ascii_string_add_flat_result); @@ -13194,9 +13199,9 @@ void StringHelper::GenerateCopyCharactersREP(MacroAssembler* masm, Register count, Register scratch, bool ascii) { - // Copy characters using rep movs of doublewords. Align destination on 4 byte - // boundary before starting rep movs. Copy remaining characters after running - // rep movs. + // Copy characters using rep movs of doublewords. + // The destination is aligned on a 4 byte boundary because we are + // copying to the beginning of a newly allocated string. ASSERT(dest.is(edi)); // rep movs destination ASSERT(src.is(esi)); // rep movs source ASSERT(count.is(ecx)); // rep movs count @@ -13317,9 +13322,9 @@ void StringHelper::GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm, } __ and_(scratch, Operand(mask)); - // Load the entry from the symble table. + // Load the entry from the symbol table. Register candidate = scratch; // Scratch register contains candidate. - ASSERT_EQ(1, SymbolTable::kEntrySize); + STATIC_ASSERT(SymbolTable::kEntrySize == 1); __ mov(candidate, FieldOperand(symbol_table, scratch, @@ -13362,7 +13367,7 @@ void StringHelper::GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm, // Scratch register contains result when we fall through to here. Register result = scratch; __ bind(&found_in_symbol_table); - __ pop(mask); // Pop temporally saved mask from the stack. + __ pop(mask); // Pop saved mask from the stack. if (!result.is(eax)) { __ mov(eax, result); } @@ -13437,7 +13442,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { // Make sure first argument is a string. __ mov(eax, Operand(esp, 3 * kPointerSize)); - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); __ test(eax, Immediate(kSmiTagMask)); __ j(zero, &runtime); Condition is_string = masm->IsObjectStringType(eax, ebx, ebx); @@ -13445,6 +13450,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { // eax: string // ebx: instance type + // Calculate length of sub string using the smi values. Label result_longer_than_two; __ mov(ecx, Operand(esp, 1 * kPointerSize)); // To index. @@ -13550,8 +13556,8 @@ void SubStringStub::Generate(MacroAssembler* masm) { __ mov(ebx, Operand(esp, 2 * kPointerSize)); // from // As from is a smi it is 2 times the value which matches the size of a two // byte character. - ASSERT_EQ(0, kSmiTag); - ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize); + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); __ add(esi, Operand(ebx)); // eax: result string @@ -13637,8 +13643,8 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, __ j(not_zero, &result_not_equal); // Result is EQUAL. - ASSERT_EQ(0, EQUAL); - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(EQUAL == 0); + STATIC_ASSERT(kSmiTag == 0); __ Set(eax, Immediate(Smi::FromInt(EQUAL))); __ ret(0); @@ -13670,8 +13676,8 @@ void StringCompareStub::Generate(MacroAssembler* masm) { Label not_same; __ cmp(edx, Operand(eax)); __ j(not_equal, ¬_same); - ASSERT_EQ(0, EQUAL); - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(EQUAL == 0); + STATIC_ASSERT(kSmiTag == 0); __ Set(eax, Immediate(Smi::FromInt(EQUAL))); __ IncrementCounter(&Counters::string_compare_native, 1); __ ret(2 * kPointerSize); diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index 88ad606973..1cb8cc3be0 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -2100,9 +2100,9 @@ void CodeGenerator::Comparison(AstNode* node, // side (which is always a symbol). if (cc == equal) { Label not_a_symbol; - ASSERT(kSymbolTag != 0); + STATIC_ASSERT(kSymbolTag != 0); // Ensure that no non-strings have the symbol bit set. - ASSERT(kNotStringTag + kIsSymbolMask > LAST_TYPE); + STATIC_ASSERT(LAST_TYPE < kNotStringTag + kIsSymbolMask); __ testb(temp.reg(), Immediate(kIsSymbolMask)); // Test the symbol bit. __ j(zero, ¬_a_symbol); // They are symbols, so do identity compare. @@ -2567,8 +2567,8 @@ void CodeGenerator::CallApplyLazy(Expression* applicand, // JS_FUNCTION_TYPE is the last instance type and it is right // after LAST_JS_OBJECT_TYPE, we do not have to check the upper // bound. - ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); - ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); + STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); + STATIC_ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rcx); __ j(below, &build_args); @@ -4011,7 +4011,7 @@ void CodeGenerator::VisitTryCatchStatement(TryCatchStatement* node) { // The next handler address is on top of the frame. Unlink from // the handler list and drop the rest of this handler from the // frame. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); __ movq(kScratchRegister, handler_address); frame_->EmitPop(Operand(kScratchRegister, 0)); frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); @@ -4044,7 +4044,7 @@ void CodeGenerator::VisitTryCatchStatement(TryCatchStatement* node) { __ movq(rsp, Operand(kScratchRegister, 0)); frame_->Forget(frame_->height() - handler_height); - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); __ movq(kScratchRegister, handler_address); frame_->EmitPop(Operand(kScratchRegister, 0)); frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); @@ -4131,7 +4131,7 @@ void CodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* node) { // chain and set the state on the frame to FALLING. if (has_valid_frame()) { // The next handler address is on top of the frame. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); __ movq(kScratchRegister, handler_address); frame_->EmitPop(Operand(kScratchRegister, 0)); frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); @@ -4172,7 +4172,7 @@ void CodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* node) { frame_->Forget(frame_->height() - handler_height); // Unlink this handler and drop it from the frame. - ASSERT(StackHandlerConstants::kNextOffset == 0); + STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); __ movq(kScratchRegister, handler_address); frame_->EmitPop(Operand(kScratchRegister, 0)); frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); @@ -6192,7 +6192,7 @@ void CodeGenerator::GenerateGetFramePointer(ZoneList* args) { ASSERT(args->length() == 0); // RBP value is aligned, so it should be tagged as a smi (without necesarily // being padded as a smi, so it should not be treated as a smi.). - ASSERT(kSmiTag == 0 && kSmiTagSize == 1); + STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); Result rbp_as_smi = allocator_->Allocate(); ASSERT(rbp_as_smi.is_valid()); __ movq(rbp_as_smi.reg(), rbp); @@ -10111,7 +10111,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ j(not_equal, &runtime); // Check that the last match info has space for the capture registers and the // additional information. Ensure no overflow in add. - ASSERT(FixedArray::kMaxLength < kMaxInt - FixedArray::kLengthOffset); + STATIC_ASSERT(FixedArray::kMaxLength < kMaxInt - FixedArray::kLengthOffset); __ SmiToInteger32(rax, FieldOperand(rbx, FixedArray::kLengthOffset)); __ addl(rdx, Immediate(RegExpImpl::kLastMatchOverhead)); __ cmpl(rdx, rax); @@ -10126,7 +10126,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // First check for flat two byte string. __ andb(rbx, Immediate( kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask)); - ASSERT_EQ(0, kStringTag | kSeqStringTag | kTwoByteStringTag); + STATIC_ASSERT((kStringTag | kSeqStringTag | kTwoByteStringTag) == 0); __ j(zero, &seq_two_byte_string); // Any other flat string must be a flat ascii string. __ testb(rbx, Immediate(kIsNotStringMask | kStringRepresentationMask)); @@ -10137,8 +10137,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // string. In that case the subject string is just the first part of the cons // string. Also in this case the first part of the cons string is known to be // a sequential string or an external string. - ASSERT(kExternalStringTag !=0); - ASSERT_EQ(0, kConsStringTag & kExternalStringTag); + STATIC_ASSERT(kExternalStringTag !=0); + STATIC_ASSERT((kConsStringTag & kExternalStringTag) == 0); __ testb(rbx, Immediate(kIsNotStringMask | kExternalStringTag)); __ j(not_zero, &runtime); // String is a cons string. @@ -10153,7 +10153,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // Is first part a flat two byte string? __ testb(FieldOperand(rbx, Map::kInstanceTypeOffset), Immediate(kStringRepresentationMask | kStringEncodingMask)); - ASSERT_EQ(0, kSeqStringTag | kTwoByteStringTag); + STATIC_ASSERT((kSeqStringTag | kTwoByteStringTag) == 0); __ j(zero, &seq_two_byte_string); // Any other flat string must be ascii. __ testb(FieldOperand(rbx, Map::kInstanceTypeOffset), @@ -10390,7 +10390,7 @@ void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm, __ JumpIfSmi(object, &is_smi); __ CheckMap(object, Factory::heap_number_map(), not_found, true); - ASSERT_EQ(8, kDoubleSize); + STATIC_ASSERT(8 == kDoubleSize); __ movl(scratch, FieldOperand(object, HeapNumber::kValueOffset + 4)); __ xor_(scratch, FieldOperand(object, HeapNumber::kValueOffset)); GenerateConvertHashCodeToIndex(masm, scratch, mask); @@ -10571,13 +10571,13 @@ void CompareStub::Generate(MacroAssembler* masm) { // There is no test for undetectability in strict equality. // If the first object is a JS object, we have done pointer comparison. - ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); + STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); Label first_non_object; __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rcx); __ j(below, &first_non_object); // Return non-zero (eax (not rax) is not zero) Label return_not_equal; - ASSERT(kHeapObjectTag != 0); + STATIC_ASSERT(kHeapObjectTag != 0); __ bind(&return_not_equal); __ ret(0); @@ -10669,8 +10669,8 @@ void CompareStub::Generate(MacroAssembler* masm) { // At most one is a smi, so we can test for smi by adding the two. // A smi plus a heap object has the low bit set, a heap object plus // a heap object has the low bit clear. - ASSERT_EQ(0, kSmiTag); - ASSERT_EQ(static_cast(1), kSmiTagMask); + STATIC_ASSERT(kSmiTag == 0); + STATIC_ASSERT(kSmiTagMask == 1); __ lea(rcx, Operand(rax, rdx, times_1, 0)); __ testb(rcx, Immediate(kSmiTagMask)); __ j(not_zero, ¬_both_objects); @@ -10726,8 +10726,8 @@ void CompareStub::BranchIfNonSymbol(MacroAssembler* masm, __ movzxbq(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); // Ensure that no non-strings have the symbol bit set. - ASSERT(kNotStringTag + kIsSymbolMask > LAST_TYPE); - ASSERT(kSymbolTag != 0); + STATIC_ASSERT(LAST_TYPE < kNotStringTag + kIsSymbolMask); + STATIC_ASSERT(kSymbolTag != 0); __ testb(scratch, Immediate(kIsSymbolMask)); __ j(zero, label); } @@ -10806,9 +10806,9 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { // Check that stack should contain next handler, frame pointer, state and // return address in that order. - ASSERT_EQ(StackHandlerConstants::kFPOffset + kPointerSize, + STATIC_ASSERT(StackHandlerConstants::kFPOffset + kPointerSize == StackHandlerConstants::kStateOffset); - ASSERT_EQ(StackHandlerConstants::kStateOffset + kPointerSize, + STATIC_ASSERT(StackHandlerConstants::kStateOffset + kPointerSize == StackHandlerConstants::kPCOffset); ExternalReference handler_address(Top::k_handler_address); @@ -10918,7 +10918,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm, // Check for failure result. Label failure_returned; - ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); + STATIC_ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); #ifdef _WIN64 // If return value is on the stack, pop it to registers. if (result_size_ > 1) { @@ -10944,7 +10944,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm, Label retry; // If the returned exception is RETRY_AFTER_GC continue at retry label - ASSERT(Failure::RETRY_AFTER_GC == 0); + STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); __ testl(rax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); __ j(zero, &retry); @@ -11014,14 +11014,14 @@ void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, __ xor_(rsi, rsi); // Restore registers from handler. - ASSERT_EQ(StackHandlerConstants::kNextOffset + kPointerSize, + STATIC_ASSERT(StackHandlerConstants::kNextOffset + kPointerSize == StackHandlerConstants::kFPOffset); __ pop(rbp); // FP - ASSERT_EQ(StackHandlerConstants::kFPOffset + kPointerSize, + STATIC_ASSERT(StackHandlerConstants::kFPOffset + kPointerSize == StackHandlerConstants::kStateOffset); __ pop(rdx); // State - ASSERT_EQ(StackHandlerConstants::kStateOffset + kPointerSize, + STATIC_ASSERT(StackHandlerConstants::kStateOffset + kPointerSize == StackHandlerConstants::kPCOffset); __ ret(0); } @@ -11296,7 +11296,7 @@ void InstanceofStub::Generate(MacroAssembler* masm) { __ bind(&is_instance); __ xorl(rax, rax); // Store bitwise zero in the cache. This is a Smi in GC terms. - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); __ StoreRoot(rax, Heap::kInstanceofCacheAnswerRootIndex); __ ret(2 * kPointerSize); @@ -11401,7 +11401,7 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { __ j(above_equal, index_out_of_range_); // We need special handling for non-flat strings. - ASSERT(kSeqStringTag == 0); + STATIC_ASSERT(kSeqStringTag == 0); __ testb(result_, Immediate(kStringRepresentationMask)); __ j(zero, &flat_string); @@ -11422,13 +11422,13 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { __ movq(result_, FieldOperand(object_, HeapObject::kMapOffset)); __ movzxbl(result_, FieldOperand(result_, Map::kInstanceTypeOffset)); // If the first cons component is also non-flat, then go to runtime. - ASSERT(kSeqStringTag == 0); + STATIC_ASSERT(kSeqStringTag == 0); __ testb(result_, Immediate(kStringRepresentationMask)); __ j(not_zero, &call_runtime_); // Check for 1-byte or 2-byte string. __ bind(&flat_string); - ASSERT(kAsciiStringTag != 0); + STATIC_ASSERT(kAsciiStringTag != 0); __ testb(result_, Immediate(kStringEncodingMask)); __ j(not_zero, &ascii_string); @@ -11622,7 +11622,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { __ movzxbl(r9, FieldOperand(r9, Map::kInstanceTypeOffset)); // Look at the length of the result of adding the two strings. - ASSERT(String::kMaxLength <= Smi::kMaxValue / 2); + STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue / 2); __ SmiAdd(rbx, rbx, rcx, NULL); // Use the runtime system when adding two one character strings, as it // contains optimizations for this specific case using the symbol table. @@ -11654,7 +11654,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { __ SmiCompare(rbx, Smi::FromInt(String::kMinNonFlatLength)); __ j(below, &string_add_flat_result); // Handle exceptionally long strings in the runtime system. - ASSERT((String::kMaxLength & 0x80000000) == 0); + STATIC_ASSERT((String::kMaxLength & 0x80000000) == 0); __ SmiCompare(rbx, Smi::FromInt(String::kMaxLength)); __ j(above, &string_add_runtime); @@ -11668,7 +11668,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { Label non_ascii, allocated, ascii_data; __ movl(rcx, r8); __ and_(rcx, r9); - ASSERT(kStringEncodingMask == kAsciiStringTag); + STATIC_ASSERT(kStringEncodingMask == kAsciiStringTag); __ testl(rcx, Immediate(kAsciiStringTag)); __ j(zero, &non_ascii); __ bind(&ascii_data); @@ -11693,7 +11693,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { __ testb(rcx, Immediate(kAsciiDataHintMask)); __ j(not_zero, &ascii_data); __ xor_(r8, r9); - ASSERT(kAsciiStringTag != 0 && kAsciiDataHintTag != 0); + STATIC_ASSERT(kAsciiStringTag != 0 && kAsciiDataHintTag != 0); __ andb(r8, Immediate(kAsciiStringTag | kAsciiDataHintTag)); __ cmpb(r8, Immediate(kAsciiStringTag | kAsciiDataHintTag)); __ j(equal, &ascii_data); @@ -11725,7 +11725,7 @@ void StringAddStub::Generate(MacroAssembler* masm) { // r8: instance type of first string // r9: instance type of second string Label non_ascii_string_add_flat_result; - ASSERT(kStringEncodingMask == kAsciiStringTag); + STATIC_ASSERT(kStringEncodingMask == kAsciiStringTag); __ testl(r8, Immediate(kAsciiStringTag)); __ j(zero, &non_ascii_string_add_flat_result); __ testl(r9, Immediate(kAsciiStringTag)); @@ -11847,7 +11847,7 @@ void StringHelper::GenerateCopyCharactersREP(MacroAssembler* masm, // Make count the number of bytes to copy. if (!ascii) { - ASSERT_EQ(2, static_cast(sizeof(uc16))); // NOLINT + STATIC_ASSERT(2 == sizeof(uc16)); __ addl(count, count); } @@ -11954,7 +11954,7 @@ void StringHelper::GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm, // Load the entry from the symble table. Register candidate = scratch; // Scratch register contains candidate. - ASSERT_EQ(1, SymbolTable::kEntrySize); + STATIC_ASSERT(SymbolTable::kEntrySize == 1); __ movq(candidate, FieldOperand(symbol_table, scratch, @@ -12069,7 +12069,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { // Make sure first argument is a string. __ movq(rax, Operand(rsp, kStringOffset)); - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); __ testl(rax, Immediate(kSmiTagMask)); __ j(zero, &runtime); Condition is_string = masm->IsObjectStringType(rax, rbx, rbx); @@ -12209,7 +12209,7 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, Register scratch4) { // Ensure that you can always subtract a string length from a non-negative // number (e.g. another length). - ASSERT(String::kMaxLength < 0x7fffffff); + STATIC_ASSERT(String::kMaxLength < 0x7fffffff); // Find minimum length and length difference. __ movq(scratch1, FieldOperand(left, String::kLengthOffset));