Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1875 Node* fdec_result = assembler->Float64Sub(fdec_value, one); | 1875 Node* fdec_result = assembler->Float64Sub(fdec_value, one); |
| 1876 result_var.Bind(assembler->ChangeFloat64ToTagged(fdec_result)); | 1876 result_var.Bind(assembler->ChangeFloat64ToTagged(fdec_result)); |
| 1877 assembler->Goto(&end); | 1877 assembler->Goto(&end); |
| 1878 } | 1878 } |
| 1879 | 1879 |
| 1880 assembler->Bind(&end); | 1880 assembler->Bind(&end); |
| 1881 return result_var.value(); | 1881 return result_var.value(); |
| 1882 } | 1882 } |
| 1883 | 1883 |
| 1884 // static | 1884 // static |
| 1885 // ES6 section 12.5.5 typeof operator | |
| 1886 compiler::Node* TypeofStub::Generate(CodeStubAssembler* assembler, | |
| 1887 compiler::Node* value, | |
| 1888 compiler::Node* context) { | |
| 1889 typedef compiler::Node Node; | |
| 1890 typedef CodeStubAssembler::Label Label; | |
| 1891 typedef CodeStubAssembler::Variable Variable; | |
| 1892 | |
| 1893 Variable result_var(assembler, MachineRepresentation::kTagged); | |
| 1894 | |
| 1895 Label return_undefined(assembler), return_number(assembler, Label::kDeferred), | |
| 1896 return_string(assembler), return_symbol(assembler, Label::kDeferred), | |
| 1897 return_function(assembler), if_oddball(assembler), if_object(assembler), | |
| 1898 end(assembler); | |
|
Benedikt Meurer
2016/08/01 17:27:42
Nit: I'd prefer to use return_result instead of en
Franzi
2016/08/01 19:00:33
Done.
| |
| 1899 | |
| 1900 assembler->GotoIf(assembler->WordIsSmi(value), &return_number); | |
| 1901 | |
| 1902 Node* map = assembler->LoadMap(value); | |
| 1903 | |
| 1904 assembler->GotoIf( | |
| 1905 assembler->WordEqual(map, assembler->HeapNumberMapConstant()), | |
| 1906 &return_number); | |
| 1907 | |
| 1908 Node* instance_type = assembler->LoadInstanceType(value); | |
| 1909 | |
| 1910 assembler->GotoIf( | |
| 1911 assembler->Int32LessThan(instance_type, | |
| 1912 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), | |
| 1913 &return_string); | |
| 1914 | |
| 1915 assembler->GotoIf(assembler->Word32Equal( | |
| 1916 instance_type, assembler->Int32Constant(ODDBALL_TYPE)), | |
| 1917 &if_oddball); | |
| 1918 | |
| 1919 assembler->GotoIf(assembler->Word32Equal( | |
| 1920 instance_type, assembler->Int32Constant(SYMBOL_TYPE)), | |
| 1921 &return_symbol); | |
| 1922 | |
| 1923 assembler->GotoIf(assembler->Word32NotEqual( | |
|
Benedikt Meurer
2016/08/01 17:27:42
Nit: Use GotoUnless with Word32Equal instead.
Franzi
2016/08/01 19:00:32
Done.
| |
| 1924 assembler->Word32And(assembler->LoadMapBitField(map), | |
| 1925 assembler->Int32Constant( | |
| 1926 1 << Map::kIsUndetectable)), | |
| 1927 assembler->Int32Constant(0)), | |
| 1928 &return_undefined); | |
| 1929 | |
| 1930 assembler->Branch( | |
|
Benedikt Meurer
2016/08/01 17:27:42
Nit: Use GotoIf here as well, and continue the fla
Franzi
2016/08/01 19:00:32
Done.
| |
| 1931 assembler->Word32Equal( | |
| 1932 assembler->Word32And(assembler->LoadMapBitField(map), | |
| 1933 assembler->Int32Constant(1 << Map::kIsCallable)), | |
| 1934 assembler->Int32Constant(0)), | |
| 1935 &if_object, &return_function); | |
|
Benedikt Meurer
2016/08/01 17:27:42
I think we could rearrange it a bit, so that we ch
Franzi
2016/08/01 19:00:32
Changed the order. Makes sense to have the unlikel
| |
| 1936 | |
| 1937 assembler->Bind(&if_oddball); | |
| 1938 { | |
| 1939 Node* type = assembler->LoadObjectField(value, Oddball::kTypeOfOffset); | |
| 1940 result_var.Bind(type); | |
| 1941 assembler->Goto(&end); | |
| 1942 } | |
| 1943 | |
| 1944 assembler->Bind(&if_object); | |
| 1945 { | |
| 1946 #define SIMD128_BRANCH(TYPE, Type, type, lane_count, lane_type) \ | |
| 1947 Label return_##type(assembler); \ | |
| 1948 Node* type##_map = \ | |
| 1949 assembler->HeapConstant(assembler->factory()->type##_map()); \ | |
| 1950 assembler->GotoIf(assembler->WordEqual(map, type##_map), &return_##type); | |
| 1951 SIMD128_TYPES(SIMD128_BRANCH) | |
| 1952 #undef SIMD128_BRANCH | |
| 1953 | |
| 1954 result_var.Bind(assembler->HeapConstant( | |
| 1955 assembler->isolate()->factory()->object_string())); | |
| 1956 assembler->Goto(&end); | |
| 1957 | |
| 1958 #define SIMD128_BIND_RETURN(TYPE, Type, type, lane_count, lane_type) \ | |
| 1959 assembler->Bind(&return_##type); \ | |
| 1960 { \ | |
| 1961 result_var.Bind(assembler->HeapConstant( \ | |
| 1962 assembler->isolate()->factory()->type##_string())); \ | |
| 1963 assembler->Goto(&end); \ | |
| 1964 } | |
| 1965 SIMD128_TYPES(SIMD128_BIND_RETURN) | |
| 1966 #undef SIMD128_BIND_RETURN | |
| 1967 } | |
| 1968 | |
| 1969 assembler->Bind(&return_number); | |
| 1970 { | |
| 1971 result_var.Bind(assembler->HeapConstant( | |
| 1972 assembler->isolate()->factory()->number_string())); | |
| 1973 assembler->Goto(&end); | |
| 1974 } | |
| 1975 | |
| 1976 assembler->Bind(&return_string); | |
| 1977 { | |
| 1978 result_var.Bind(assembler->HeapConstant( | |
| 1979 assembler->isolate()->factory()->string_string())); | |
| 1980 assembler->Goto(&end); | |
| 1981 } | |
| 1982 | |
| 1983 assembler->Bind(&return_symbol); | |
| 1984 { | |
| 1985 result_var.Bind(assembler->HeapConstant( | |
| 1986 assembler->isolate()->factory()->symbol_string())); | |
| 1987 assembler->Goto(&end); | |
| 1988 } | |
| 1989 | |
| 1990 assembler->Bind(&return_undefined); | |
| 1991 { | |
| 1992 result_var.Bind(assembler->HeapConstant( | |
| 1993 assembler->isolate()->factory()->undefined_string())); | |
| 1994 assembler->Goto(&end); | |
| 1995 } | |
| 1996 | |
| 1997 assembler->Bind(&return_function); | |
| 1998 { | |
| 1999 result_var.Bind(assembler->HeapConstant( | |
| 2000 assembler->isolate()->factory()->function_string())); | |
| 2001 assembler->Goto(&end); | |
| 2002 } | |
| 2003 | |
| 2004 assembler->Bind(&end); | |
| 2005 return result_var.value(); | |
| 2006 } | |
| 2007 | |
| 2008 // static | |
| 1885 compiler::Node* InstanceOfStub::Generate(CodeStubAssembler* assembler, | 2009 compiler::Node* InstanceOfStub::Generate(CodeStubAssembler* assembler, |
| 1886 compiler::Node* object, | 2010 compiler::Node* object, |
| 1887 compiler::Node* callable, | 2011 compiler::Node* callable, |
| 1888 compiler::Node* context) { | 2012 compiler::Node* context) { |
| 1889 typedef CodeStubAssembler::Label Label; | 2013 typedef CodeStubAssembler::Label Label; |
| 1890 typedef CodeStubAssembler::Variable Variable; | 2014 typedef CodeStubAssembler::Variable Variable; |
| 1891 | 2015 |
| 1892 Label return_runtime(assembler, Label::kDeferred), end(assembler); | 2016 Label return_runtime(assembler, Label::kDeferred), end(assembler); |
| 1893 Variable result(assembler, MachineRepresentation::kTagged); | 2017 Variable result(assembler, MachineRepresentation::kTagged); |
| 1894 | 2018 |
| (...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4093 void ToObjectStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4217 void ToObjectStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4094 descriptor->Initialize(Runtime::FunctionForId(Runtime::kToObject)->entry); | 4218 descriptor->Initialize(Runtime::FunctionForId(Runtime::kToObject)->entry); |
| 4095 descriptor->SetMissHandler(Runtime::kToObject); | 4219 descriptor->SetMissHandler(Runtime::kToObject); |
| 4096 } | 4220 } |
| 4097 | 4221 |
| 4098 void StoreTransitionStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4222 void StoreTransitionStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4099 descriptor->Initialize( | 4223 descriptor->Initialize( |
| 4100 FUNCTION_ADDR(Runtime_TransitionStoreIC_MissFromStubFailure)); | 4224 FUNCTION_ADDR(Runtime_TransitionStoreIC_MissFromStubFailure)); |
| 4101 } | 4225 } |
| 4102 | 4226 |
| 4103 void TypeofStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | |
| 4104 descriptor->SetMissHandler(Runtime::kTypeof); | |
| 4105 } | |
| 4106 | |
| 4107 void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4227 void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4108 descriptor->Initialize( | 4228 descriptor->Initialize( |
| 4109 Runtime::FunctionForId(Runtime::kNumberToString)->entry); | 4229 Runtime::FunctionForId(Runtime::kNumberToString)->entry); |
| 4110 descriptor->SetMissHandler(Runtime::kNumberToString); | 4230 descriptor->SetMissHandler(Runtime::kNumberToString); |
| 4111 } | 4231 } |
| 4112 | 4232 |
| 4113 | 4233 |
| 4114 void FastCloneRegExpStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4234 void FastCloneRegExpStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4115 FastCloneRegExpDescriptor call_descriptor(isolate()); | 4235 FastCloneRegExpDescriptor call_descriptor(isolate()); |
| 4116 descriptor->Initialize( | 4236 descriptor->Initialize( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4183 } | 4303 } |
| 4184 | 4304 |
| 4185 | 4305 |
| 4186 void GrowArrayElementsStub::InitializeDescriptor( | 4306 void GrowArrayElementsStub::InitializeDescriptor( |
| 4187 CodeStubDescriptor* descriptor) { | 4307 CodeStubDescriptor* descriptor) { |
| 4188 descriptor->Initialize( | 4308 descriptor->Initialize( |
| 4189 Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); | 4309 Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); |
| 4190 } | 4310 } |
| 4191 | 4311 |
| 4192 | 4312 |
| 4193 void TypeofStub::GenerateAheadOfTime(Isolate* isolate) { | |
| 4194 TypeofStub stub(isolate); | |
| 4195 stub.GetCode(); | |
| 4196 } | |
| 4197 | |
| 4198 namespace { | 4313 namespace { |
| 4199 | 4314 |
| 4200 compiler::Node* GenerateHasProperty( | 4315 compiler::Node* GenerateHasProperty( |
| 4201 CodeStubAssembler* assembler, compiler::Node* object, compiler::Node* key, | 4316 CodeStubAssembler* assembler, compiler::Node* object, compiler::Node* key, |
| 4202 compiler::Node* context, Runtime::FunctionId fallback_runtime_function_id) { | 4317 compiler::Node* context, Runtime::FunctionId fallback_runtime_function_id) { |
| 4203 typedef compiler::Node Node; | 4318 typedef compiler::Node Node; |
| 4204 typedef CodeStubAssembler::Label Label; | 4319 typedef CodeStubAssembler::Label Label; |
| 4205 typedef CodeStubAssembler::Variable Variable; | 4320 typedef CodeStubAssembler::Variable Variable; |
| 4206 | 4321 |
| 4207 Label call_runtime(assembler, Label::kDeferred), return_true(assembler), | 4322 Label call_runtime(assembler, Label::kDeferred), return_true(assembler), |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4932 if (type->Is(Type::UntaggedPointer())) { | 5047 if (type->Is(Type::UntaggedPointer())) { |
| 4933 return Representation::External(); | 5048 return Representation::External(); |
| 4934 } | 5049 } |
| 4935 | 5050 |
| 4936 DCHECK(!type->Is(Type::Untagged())); | 5051 DCHECK(!type->Is(Type::Untagged())); |
| 4937 return Representation::Tagged(); | 5052 return Representation::Tagged(); |
| 4938 } | 5053 } |
| 4939 | 5054 |
| 4940 } // namespace internal | 5055 } // namespace internal |
| 4941 } // namespace v8 | 5056 } // namespace v8 |
| OLD | NEW |