Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 11108011: Ensure that we do not accidentally emit debug code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed indentation Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 RememberedSetAction remembered_set_action, 389 RememberedSetAction remembered_set_action,
390 SmiCheck smi_check) { 390 SmiCheck smi_check) {
391 // The compiled code assumes that record write doesn't change the 391 // The compiled code assumes that record write doesn't change the
392 // context register, so we check that none of the clobbered 392 // context register, so we check that none of the clobbered
393 // registers are rsi. 393 // registers are rsi.
394 ASSERT(!value.is(rsi) && !address.is(rsi)); 394 ASSERT(!value.is(rsi) && !address.is(rsi));
395 395
396 ASSERT(!object.is(value)); 396 ASSERT(!object.is(value));
397 ASSERT(!object.is(address)); 397 ASSERT(!object.is(address));
398 ASSERT(!value.is(address)); 398 ASSERT(!value.is(address));
399 if (emit_debug_code()) { 399 AssertNotSmi(object);
400 AbortIfSmi(object);
401 }
402 400
403 if (remembered_set_action == OMIT_REMEMBERED_SET && 401 if (remembered_set_action == OMIT_REMEMBERED_SET &&
404 !FLAG_incremental_marking) { 402 !FLAG_incremental_marking) {
405 return; 403 return;
406 } 404 }
407 405
408 if (emit_debug_code()) { 406 if (emit_debug_code()) {
409 Label ok; 407 Label ok;
410 cmpq(value, Operand(address, 0)); 408 cmpq(value, Operand(address, 0));
411 j(equal, &ok, Label::kNear); 409 j(equal, &ok, Label::kNear);
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 movsxlq(dst, Operand(src, kSmiShift / kBitsPerByte)); 1106 movsxlq(dst, Operand(src, kSmiShift / kBitsPerByte));
1109 } 1107 }
1110 1108
1111 1109
1112 void MacroAssembler::SmiTest(Register src) { 1110 void MacroAssembler::SmiTest(Register src) {
1113 testq(src, src); 1111 testq(src, src);
1114 } 1112 }
1115 1113
1116 1114
1117 void MacroAssembler::SmiCompare(Register smi1, Register smi2) { 1115 void MacroAssembler::SmiCompare(Register smi1, Register smi2) {
1118 if (emit_debug_code()) { 1116 AssertSmi(smi1);
1119 AbortIfNotSmi(smi1); 1117 AssertSmi(smi2);
1120 AbortIfNotSmi(smi2);
1121 }
1122 cmpq(smi1, smi2); 1118 cmpq(smi1, smi2);
1123 } 1119 }
1124 1120
1125 1121
1126 void MacroAssembler::SmiCompare(Register dst, Smi* src) { 1122 void MacroAssembler::SmiCompare(Register dst, Smi* src) {
1127 if (emit_debug_code()) { 1123 AssertSmi(dst);
1128 AbortIfNotSmi(dst);
1129 }
1130 Cmp(dst, src); 1124 Cmp(dst, src);
1131 } 1125 }
1132 1126
1133 1127
1134 void MacroAssembler::Cmp(Register dst, Smi* src) { 1128 void MacroAssembler::Cmp(Register dst, Smi* src) {
1135 ASSERT(!dst.is(kScratchRegister)); 1129 ASSERT(!dst.is(kScratchRegister));
1136 if (src->value() == 0) { 1130 if (src->value() == 0) {
1137 testq(dst, dst); 1131 testq(dst, dst);
1138 } else { 1132 } else {
1139 Register constant_reg = GetSmiConstant(src); 1133 Register constant_reg = GetSmiConstant(src);
1140 cmpq(dst, constant_reg); 1134 cmpq(dst, constant_reg);
1141 } 1135 }
1142 } 1136 }
1143 1137
1144 1138
1145 void MacroAssembler::SmiCompare(Register dst, const Operand& src) { 1139 void MacroAssembler::SmiCompare(Register dst, const Operand& src) {
1146 if (emit_debug_code()) { 1140 AssertSmi(dst);
1147 AbortIfNotSmi(dst); 1141 AssertSmi(src);
1148 AbortIfNotSmi(src);
1149 }
1150 cmpq(dst, src); 1142 cmpq(dst, src);
1151 } 1143 }
1152 1144
1153 1145
1154 void MacroAssembler::SmiCompare(const Operand& dst, Register src) { 1146 void MacroAssembler::SmiCompare(const Operand& dst, Register src) {
1155 if (emit_debug_code()) { 1147 AssertSmi(dst);
1156 AbortIfNotSmi(dst); 1148 AssertSmi(src);
1157 AbortIfNotSmi(src);
1158 }
1159 cmpq(dst, src); 1149 cmpq(dst, src);
1160 } 1150 }
1161 1151
1162 1152
1163 void MacroAssembler::SmiCompare(const Operand& dst, Smi* src) { 1153 void MacroAssembler::SmiCompare(const Operand& dst, Smi* src) {
1164 if (emit_debug_code()) { 1154 AssertSmi(dst);
1165 AbortIfNotSmi(dst);
1166 }
1167 cmpl(Operand(dst, kSmiShift / kBitsPerByte), Immediate(src->value())); 1155 cmpl(Operand(dst, kSmiShift / kBitsPerByte), Immediate(src->value()));
1168 } 1156 }
1169 1157
1170 1158
1171 void MacroAssembler::Cmp(const Operand& dst, Smi* src) { 1159 void MacroAssembler::Cmp(const Operand& dst, Smi* src) {
1172 // The Operand cannot use the smi register. 1160 // The Operand cannot use the smi register.
1173 Register smi_reg = GetSmiConstant(src); 1161 Register smi_reg = GetSmiConstant(src);
1174 ASSERT(!dst.AddressUsesRegister(smi_reg)); 1162 ASSERT(!dst.AddressUsesRegister(smi_reg));
1175 cmpq(dst, smi_reg); 1163 cmpq(dst, smi_reg);
1176 } 1164 }
(...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after
2964 if (smi_check_type == DO_SMI_CHECK) { 2952 if (smi_check_type == DO_SMI_CHECK) {
2965 JumpIfSmi(obj, &fail); 2953 JumpIfSmi(obj, &fail);
2966 } 2954 }
2967 Cmp(FieldOperand(obj, HeapObject::kMapOffset), map); 2955 Cmp(FieldOperand(obj, HeapObject::kMapOffset), map);
2968 j(equal, success, RelocInfo::CODE_TARGET); 2956 j(equal, success, RelocInfo::CODE_TARGET);
2969 2957
2970 bind(&fail); 2958 bind(&fail);
2971 } 2959 }
2972 2960
2973 2961
2974 void MacroAssembler::AbortIfNotNumber(Register object) { 2962 void MacroAssembler::AssertNumber(Register object) {
2975 Label ok; 2963 if (emit_debug_code()) {
2976 Condition is_smi = CheckSmi(object); 2964 Label ok;
2977 j(is_smi, &ok, Label::kNear); 2965 Condition is_smi = CheckSmi(object);
2978 Cmp(FieldOperand(object, HeapObject::kMapOffset), 2966 j(is_smi, &ok, Label::kNear);
2979 isolate()->factory()->heap_number_map()); 2967 Cmp(FieldOperand(object, HeapObject::kMapOffset),
2980 Assert(equal, "Operand not a number"); 2968 isolate()->factory()->heap_number_map());
2981 bind(&ok); 2969 Check(equal, "Operand is not a number");
2970 bind(&ok);
2971 }
2982 } 2972 }
2983 2973
2984 2974
2985 void MacroAssembler::AbortIfSmi(Register object) { 2975 void MacroAssembler::AssertNotSmi(Register object) {
2986 Condition is_smi = CheckSmi(object); 2976 if (emit_debug_code()) {
2987 Assert(NegateCondition(is_smi), "Operand is a smi"); 2977 Condition is_smi = CheckSmi(object);
2978 Check(NegateCondition(is_smi), "Operand is a smi");
2979 }
2988 } 2980 }
2989 2981
2990 2982
2991 void MacroAssembler::AbortIfNotSmi(Register object) { 2983 void MacroAssembler::AssertSmi(Register object) {
2992 Condition is_smi = CheckSmi(object); 2984 if (emit_debug_code()) {
2993 Assert(is_smi, "Operand is not a smi"); 2985 Condition is_smi = CheckSmi(object);
2986 Check(is_smi, "Operand is not a smi");
2987 }
2994 } 2988 }
2995 2989
2996 2990
2997 void MacroAssembler::AbortIfNotSmi(const Operand& object) { 2991 void MacroAssembler::AssertSmi(const Operand& object) {
2998 Condition is_smi = CheckSmi(object); 2992 if (emit_debug_code()) {
2999 Assert(is_smi, "Operand is not a smi"); 2993 Condition is_smi = CheckSmi(object);
2994 Check(is_smi, "Operand is not a smi");
2995 }
3000 } 2996 }
3001 2997
3002 2998
3003 void MacroAssembler::AbortIfNotZeroExtended(Register int32_register) { 2999 void MacroAssembler::AssertZeroExtended(Register int32_register) {
3004 ASSERT(!int32_register.is(kScratchRegister)); 3000 if (emit_debug_code()) {
3005 movq(kScratchRegister, 0x100000000l, RelocInfo::NONE); 3001 ASSERT(!int32_register.is(kScratchRegister));
3006 cmpq(kScratchRegister, int32_register); 3002 movq(kScratchRegister, 0x100000000l, RelocInfo::NONE);
3007 Assert(above_equal, "32 bit value in register is not zero-extended"); 3003 cmpq(kScratchRegister, int32_register);
3004 Check(above_equal, "32 bit value in register is not zero-extended");
3005 }
3008 } 3006 }
3009 3007
3010 3008
3011 void MacroAssembler::AbortIfNotString(Register object) { 3009 void MacroAssembler::AssertString(Register object) {
3012 testb(object, Immediate(kSmiTagMask)); 3010 if (emit_debug_code()) {
3013 Assert(not_equal, "Operand is not a string"); 3011 testb(object, Immediate(kSmiTagMask));
3014 push(object); 3012 Check(not_equal, "Operand is a smi and not a string");
3015 movq(object, FieldOperand(object, HeapObject::kMapOffset)); 3013 push(object);
3016 CmpInstanceType(object, FIRST_NONSTRING_TYPE); 3014 movq(object, FieldOperand(object, HeapObject::kMapOffset));
3017 pop(object); 3015 CmpInstanceType(object, FIRST_NONSTRING_TYPE);
3018 Assert(below, "Operand is not a string"); 3016 pop(object);
3017 Check(below, "Operand is not a string");
3018 }
3019 } 3019 }
3020 3020
3021 3021
3022 void MacroAssembler::AbortIfNotRootValue(Register src, 3022 void MacroAssembler::AssertRootValue(Register src,
3023 Heap::RootListIndex root_value_index, 3023 Heap::RootListIndex root_value_index,
3024 const char* message) { 3024 const char* message) {
3025 ASSERT(!src.is(kScratchRegister)); 3025 if (emit_debug_code()) {
3026 LoadRoot(kScratchRegister, root_value_index); 3026 ASSERT(!src.is(kScratchRegister));
3027 cmpq(src, kScratchRegister); 3027 LoadRoot(kScratchRegister, root_value_index);
3028 Check(equal, message); 3028 cmpq(src, kScratchRegister);
3029 Check(equal, message);
3030 }
3029 } 3031 }
3030 3032
3031 3033
3032 3034
3033 Condition MacroAssembler::IsObjectStringType(Register heap_object, 3035 Condition MacroAssembler::IsObjectStringType(Register heap_object,
3034 Register map, 3036 Register map,
3035 Register instance_type) { 3037 Register instance_type) {
3036 movq(map, FieldOperand(heap_object, HeapObject::kMapOffset)); 3038 movq(map, FieldOperand(heap_object, HeapObject::kMapOffset));
3037 movzxbl(instance_type, FieldOperand(map, Map::kInstanceTypeOffset)); 3039 movzxbl(instance_type, FieldOperand(map, Map::kInstanceTypeOffset));
3038 STATIC_ASSERT(kNotStringTag != 0); 3040 STATIC_ASSERT(kNotStringTag != 0);
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after
4571 4573
4572 movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); 4574 movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset));
4573 cmpq(rcx, null_value); 4575 cmpq(rcx, null_value);
4574 j(not_equal, &next); 4576 j(not_equal, &next);
4575 } 4577 }
4576 4578
4577 4579
4578 } } // namespace v8::internal 4580 } } // namespace v8::internal
4579 4581
4580 #endif // V8_TARGET_ARCH_X64 4582 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698