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

Side by Side Diff: src/crankshaft/mips/lithium-codegen-mips.cc

Issue 1744163002: [stubs] Introduce a proper ToBooleanStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix mips Created 4 years, 9 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
« no previous file with comments | « src/crankshaft/ia32/lithium-ia32.cc ('k') | src/crankshaft/mips/lithium-mips.cc » ('j') | 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.7 1 // Copyright 2012 the V8 project authors. All rights reserved.7
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 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 DCHECK(!info()->IsStub()); 1959 DCHECK(!info()->IsStub());
1960 DoubleRegister dbl_scratch = double_scratch0(); 1960 DoubleRegister dbl_scratch = double_scratch0();
1961 __ ldc1(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset)); 1961 __ ldc1(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset));
1962 // Test the double value. Zero and NaN are false. 1962 // Test the double value. Zero and NaN are false.
1963 EmitBranchF(instr, ogl, dbl_scratch, kDoubleRegZero); 1963 EmitBranchF(instr, ogl, dbl_scratch, kDoubleRegZero);
1964 } else if (type.IsString()) { 1964 } else if (type.IsString()) {
1965 DCHECK(!info()->IsStub()); 1965 DCHECK(!info()->IsStub());
1966 __ lw(at, FieldMemOperand(reg, String::kLengthOffset)); 1966 __ lw(at, FieldMemOperand(reg, String::kLengthOffset));
1967 EmitBranch(instr, ne, at, Operand(zero_reg)); 1967 EmitBranch(instr, ne, at, Operand(zero_reg));
1968 } else { 1968 } else {
1969 ToBooleanStub::Types expected = instr->hydrogen()->expected_input_types(); 1969 ToBooleanICStub::Types expected =
1970 instr->hydrogen()->expected_input_types();
1970 // Avoid deopts in the case where we've never executed this path before. 1971 // Avoid deopts in the case where we've never executed this path before.
1971 if (expected.IsEmpty()) expected = ToBooleanStub::Types::Generic(); 1972 if (expected.IsEmpty()) expected = ToBooleanICStub::Types::Generic();
1972 1973
1973 if (expected.Contains(ToBooleanStub::UNDEFINED)) { 1974 if (expected.Contains(ToBooleanICStub::UNDEFINED)) {
1974 // undefined -> false. 1975 // undefined -> false.
1975 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); 1976 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
1976 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); 1977 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at));
1977 } 1978 }
1978 if (expected.Contains(ToBooleanStub::BOOLEAN)) { 1979 if (expected.Contains(ToBooleanICStub::BOOLEAN)) {
1979 // Boolean -> its value. 1980 // Boolean -> its value.
1980 __ LoadRoot(at, Heap::kTrueValueRootIndex); 1981 __ LoadRoot(at, Heap::kTrueValueRootIndex);
1981 __ Branch(instr->TrueLabel(chunk_), eq, reg, Operand(at)); 1982 __ Branch(instr->TrueLabel(chunk_), eq, reg, Operand(at));
1982 __ LoadRoot(at, Heap::kFalseValueRootIndex); 1983 __ LoadRoot(at, Heap::kFalseValueRootIndex);
1983 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); 1984 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at));
1984 } 1985 }
1985 if (expected.Contains(ToBooleanStub::NULL_TYPE)) { 1986 if (expected.Contains(ToBooleanICStub::NULL_TYPE)) {
1986 // 'null' -> false. 1987 // 'null' -> false.
1987 __ LoadRoot(at, Heap::kNullValueRootIndex); 1988 __ LoadRoot(at, Heap::kNullValueRootIndex);
1988 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at)); 1989 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at));
1989 } 1990 }
1990 1991
1991 if (expected.Contains(ToBooleanStub::SMI)) { 1992 if (expected.Contains(ToBooleanICStub::SMI)) {
1992 // Smis: 0 -> false, all other -> true. 1993 // Smis: 0 -> false, all other -> true.
1993 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(zero_reg)); 1994 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(zero_reg));
1994 __ JumpIfSmi(reg, instr->TrueLabel(chunk_)); 1995 __ JumpIfSmi(reg, instr->TrueLabel(chunk_));
1995 } else if (expected.NeedsMap()) { 1996 } else if (expected.NeedsMap()) {
1996 // If we need a map later and have a Smi -> deopt. 1997 // If we need a map later and have a Smi -> deopt.
1997 __ SmiTst(reg, at); 1998 __ SmiTst(reg, at);
1998 DeoptimizeIf(eq, instr, Deoptimizer::kSmi, at, Operand(zero_reg)); 1999 DeoptimizeIf(eq, instr, Deoptimizer::kSmi, at, Operand(zero_reg));
1999 } 2000 }
2000 2001
2001 const Register map = scratch0(); 2002 const Register map = scratch0();
2002 if (expected.NeedsMap()) { 2003 if (expected.NeedsMap()) {
2003 __ lw(map, FieldMemOperand(reg, HeapObject::kMapOffset)); 2004 __ lw(map, FieldMemOperand(reg, HeapObject::kMapOffset));
2004 if (expected.CanBeUndetectable()) { 2005 if (expected.CanBeUndetectable()) {
2005 // Undetectable -> false. 2006 // Undetectable -> false.
2006 __ lbu(at, FieldMemOperand(map, Map::kBitFieldOffset)); 2007 __ lbu(at, FieldMemOperand(map, Map::kBitFieldOffset));
2007 __ And(at, at, Operand(1 << Map::kIsUndetectable)); 2008 __ And(at, at, Operand(1 << Map::kIsUndetectable));
2008 __ Branch(instr->FalseLabel(chunk_), ne, at, Operand(zero_reg)); 2009 __ Branch(instr->FalseLabel(chunk_), ne, at, Operand(zero_reg));
2009 } 2010 }
2010 } 2011 }
2011 2012
2012 if (expected.Contains(ToBooleanStub::SPEC_OBJECT)) { 2013 if (expected.Contains(ToBooleanICStub::SPEC_OBJECT)) {
2013 // spec object -> true. 2014 // spec object -> true.
2014 __ lbu(at, FieldMemOperand(map, Map::kInstanceTypeOffset)); 2015 __ lbu(at, FieldMemOperand(map, Map::kInstanceTypeOffset));
2015 __ Branch(instr->TrueLabel(chunk_), 2016 __ Branch(instr->TrueLabel(chunk_),
2016 ge, at, Operand(FIRST_JS_RECEIVER_TYPE)); 2017 ge, at, Operand(FIRST_JS_RECEIVER_TYPE));
2017 } 2018 }
2018 2019
2019 if (expected.Contains(ToBooleanStub::STRING)) { 2020 if (expected.Contains(ToBooleanICStub::STRING)) {
2020 // String value -> false iff empty. 2021 // String value -> false iff empty.
2021 Label not_string; 2022 Label not_string;
2022 __ lbu(at, FieldMemOperand(map, Map::kInstanceTypeOffset)); 2023 __ lbu(at, FieldMemOperand(map, Map::kInstanceTypeOffset));
2023 __ Branch(&not_string, ge , at, Operand(FIRST_NONSTRING_TYPE)); 2024 __ Branch(&not_string, ge , at, Operand(FIRST_NONSTRING_TYPE));
2024 __ lw(at, FieldMemOperand(reg, String::kLengthOffset)); 2025 __ lw(at, FieldMemOperand(reg, String::kLengthOffset));
2025 __ Branch(instr->TrueLabel(chunk_), ne, at, Operand(zero_reg)); 2026 __ Branch(instr->TrueLabel(chunk_), ne, at, Operand(zero_reg));
2026 __ Branch(instr->FalseLabel(chunk_)); 2027 __ Branch(instr->FalseLabel(chunk_));
2027 __ bind(&not_string); 2028 __ bind(&not_string);
2028 } 2029 }
2029 2030
2030 if (expected.Contains(ToBooleanStub::SYMBOL)) { 2031 if (expected.Contains(ToBooleanICStub::SYMBOL)) {
2031 // Symbol value -> true. 2032 // Symbol value -> true.
2032 const Register scratch = scratch1(); 2033 const Register scratch = scratch1();
2033 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); 2034 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset));
2034 __ Branch(instr->TrueLabel(chunk_), eq, scratch, Operand(SYMBOL_TYPE)); 2035 __ Branch(instr->TrueLabel(chunk_), eq, scratch, Operand(SYMBOL_TYPE));
2035 } 2036 }
2036 2037
2037 if (expected.Contains(ToBooleanStub::SIMD_VALUE)) { 2038 if (expected.Contains(ToBooleanICStub::SIMD_VALUE)) {
2038 // SIMD value -> true. 2039 // SIMD value -> true.
2039 const Register scratch = scratch1(); 2040 const Register scratch = scratch1();
2040 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); 2041 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset));
2041 __ Branch(instr->TrueLabel(chunk_), eq, scratch, 2042 __ Branch(instr->TrueLabel(chunk_), eq, scratch,
2042 Operand(SIMD128_VALUE_TYPE)); 2043 Operand(SIMD128_VALUE_TYPE));
2043 } 2044 }
2044 2045
2045 if (expected.Contains(ToBooleanStub::HEAP_NUMBER)) { 2046 if (expected.Contains(ToBooleanICStub::HEAP_NUMBER)) {
2046 // heap number -> false iff +0, -0, or NaN. 2047 // heap number -> false iff +0, -0, or NaN.
2047 DoubleRegister dbl_scratch = double_scratch0(); 2048 DoubleRegister dbl_scratch = double_scratch0();
2048 Label not_heap_number; 2049 Label not_heap_number;
2049 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); 2050 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex);
2050 __ Branch(&not_heap_number, ne, map, Operand(at)); 2051 __ Branch(&not_heap_number, ne, map, Operand(at));
2051 __ ldc1(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset)); 2052 __ ldc1(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset));
2052 __ BranchF(instr->TrueLabel(chunk_), instr->FalseLabel(chunk_), 2053 __ BranchF(instr->TrueLabel(chunk_), instr->FalseLabel(chunk_),
2053 ne, dbl_scratch, kDoubleRegZero); 2054 ne, dbl_scratch, kDoubleRegZero);
2054 // Falls through if dbl_scratch == 0. 2055 // Falls through if dbl_scratch == 0.
2055 __ Branch(instr->FalseLabel(chunk_)); 2056 __ Branch(instr->FalseLabel(chunk_));
(...skipping 3432 matching lines...) Expand 10 before | Expand all | Expand 10 after
5488 void LCodeGen::DoStoreFrameContext(LStoreFrameContext* instr) { 5489 void LCodeGen::DoStoreFrameContext(LStoreFrameContext* instr) {
5489 Register context = ToRegister(instr->context()); 5490 Register context = ToRegister(instr->context());
5490 __ sw(context, MemOperand(fp, StandardFrameConstants::kContextOffset)); 5491 __ sw(context, MemOperand(fp, StandardFrameConstants::kContextOffset));
5491 } 5492 }
5492 5493
5493 5494
5494 #undef __ 5495 #undef __
5495 5496
5496 } // namespace internal 5497 } // namespace internal
5497 } // namespace v8 5498 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/ia32/lithium-ia32.cc ('k') | src/crankshaft/mips/lithium-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698