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_number(assembler, Label::kDeferred), if_oddball(assembler), |
| 1896 return_function(assembler), return_undefined(assembler), |
| 1897 return_object(assembler), return_string(assembler), |
| 1898 return_result(assembler); |
| 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(assembler->Word32Equal( |
| 1911 instance_type, assembler->Int32Constant(ODDBALL_TYPE)), |
| 1912 &if_oddball); |
| 1913 |
| 1914 Node* callable_or_undetectable_mask = |
| 1915 assembler->Word32And(assembler->LoadMapBitField(map), |
| 1916 assembler->Int32Constant(1 << Map::kIsCallable | |
| 1917 1 << Map::kIsUndetectable)); |
| 1918 |
| 1919 assembler->GotoIf( |
| 1920 assembler->Word32Equal(callable_or_undetectable_mask, |
| 1921 assembler->Int32Constant(1 << Map::kIsCallable)), |
| 1922 &return_function); |
| 1923 |
| 1924 assembler->GotoUnless(assembler->Word32Equal(callable_or_undetectable_mask, |
| 1925 assembler->Int32Constant(0)), |
| 1926 &return_undefined); |
| 1927 |
| 1928 assembler->GotoIf( |
| 1929 assembler->Int32GreaterThanOrEqual( |
| 1930 instance_type, assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE)), |
| 1931 &return_object); |
| 1932 |
| 1933 assembler->GotoIf( |
| 1934 assembler->Int32LessThan(instance_type, |
| 1935 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), |
| 1936 &return_string); |
| 1937 |
| 1938 #define SIMD128_BRANCH(TYPE, Type, type, lane_count, lane_type) \ |
| 1939 Label return_##type(assembler); \ |
| 1940 Node* type##_map = \ |
| 1941 assembler->HeapConstant(assembler->factory()->type##_map()); \ |
| 1942 assembler->GotoIf(assembler->WordEqual(map, type##_map), &return_##type); |
| 1943 SIMD128_TYPES(SIMD128_BRANCH) |
| 1944 #undef SIMD128_BRANCH |
| 1945 |
| 1946 assembler->Assert(assembler->Word32Equal( |
| 1947 instance_type, assembler->Int32Constant(SYMBOL_TYPE))); |
| 1948 result_var.Bind(assembler->HeapConstant( |
| 1949 assembler->isolate()->factory()->symbol_string())); |
| 1950 assembler->Goto(&return_result); |
| 1951 |
| 1952 assembler->Bind(&return_number); |
| 1953 { |
| 1954 result_var.Bind(assembler->HeapConstant( |
| 1955 assembler->isolate()->factory()->number_string())); |
| 1956 assembler->Goto(&return_result); |
| 1957 } |
| 1958 |
| 1959 assembler->Bind(&if_oddball); |
| 1960 { |
| 1961 Node* type = assembler->LoadObjectField(value, Oddball::kTypeOfOffset); |
| 1962 result_var.Bind(type); |
| 1963 assembler->Goto(&return_result); |
| 1964 } |
| 1965 |
| 1966 assembler->Bind(&return_function); |
| 1967 { |
| 1968 result_var.Bind(assembler->HeapConstant( |
| 1969 assembler->isolate()->factory()->function_string())); |
| 1970 assembler->Goto(&return_result); |
| 1971 } |
| 1972 |
| 1973 assembler->Bind(&return_undefined); |
| 1974 { |
| 1975 result_var.Bind(assembler->HeapConstant( |
| 1976 assembler->isolate()->factory()->undefined_string())); |
| 1977 assembler->Goto(&return_result); |
| 1978 } |
| 1979 |
| 1980 assembler->Bind(&return_object); |
| 1981 { |
| 1982 result_var.Bind(assembler->HeapConstant( |
| 1983 assembler->isolate()->factory()->object_string())); |
| 1984 assembler->Goto(&return_result); |
| 1985 } |
| 1986 |
| 1987 assembler->Bind(&return_string); |
| 1988 { |
| 1989 result_var.Bind(assembler->HeapConstant( |
| 1990 assembler->isolate()->factory()->string_string())); |
| 1991 assembler->Goto(&return_result); |
| 1992 } |
| 1993 |
| 1994 #define SIMD128_BIND_RETURN(TYPE, Type, type, lane_count, lane_type) \ |
| 1995 assembler->Bind(&return_##type); \ |
| 1996 { \ |
| 1997 result_var.Bind(assembler->HeapConstant( \ |
| 1998 assembler->isolate()->factory()->type##_string())); \ |
| 1999 assembler->Goto(&return_result); \ |
| 2000 } |
| 2001 SIMD128_TYPES(SIMD128_BIND_RETURN) |
| 2002 #undef SIMD128_BIND_RETURN |
| 2003 |
| 2004 assembler->Bind(&return_result); |
| 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 |