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 { | |
Benedikt Meurer
2016/08/02 03:18:22
Nit: No need to put this into a { } block, that's
| |
1914 Node* callable_or_undetectable_mask = assembler->Word32And( | |
1915 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 result_var.Bind(assembler->HeapConstant( | |
Benedikt Meurer
2016/08/02 03:18:22
Nit: Please add an Assert here that the map is the
| |
1947 assembler->isolate()->factory()->symbol_string())); | |
1948 assembler->Goto(&return_result); | |
1949 | |
1950 assembler->Bind(&return_number); | |
1951 { | |
1952 result_var.Bind(assembler->HeapConstant( | |
1953 assembler->isolate()->factory()->number_string())); | |
1954 assembler->Goto(&return_result); | |
1955 } | |
1956 | |
1957 assembler->Bind(&if_oddball); | |
1958 { | |
1959 Node* type = assembler->LoadObjectField(value, Oddball::kTypeOfOffset); | |
1960 result_var.Bind(type); | |
1961 assembler->Goto(&return_result); | |
1962 } | |
1963 | |
1964 assembler->Bind(&return_function); | |
1965 { | |
1966 result_var.Bind(assembler->HeapConstant( | |
1967 assembler->isolate()->factory()->function_string())); | |
1968 assembler->Goto(&return_result); | |
1969 } | |
1970 | |
1971 assembler->Bind(&return_undefined); | |
1972 { | |
1973 result_var.Bind(assembler->HeapConstant( | |
1974 assembler->isolate()->factory()->undefined_string())); | |
1975 assembler->Goto(&return_result); | |
1976 } | |
1977 | |
1978 assembler->Bind(&return_object); | |
1979 { | |
1980 result_var.Bind(assembler->HeapConstant( | |
1981 assembler->isolate()->factory()->object_string())); | |
1982 assembler->Goto(&return_result); | |
1983 } | |
1984 | |
1985 assembler->Bind(&return_string); | |
1986 { | |
1987 result_var.Bind(assembler->HeapConstant( | |
1988 assembler->isolate()->factory()->string_string())); | |
1989 assembler->Goto(&return_result); | |
1990 } | |
1991 | |
1992 #define SIMD128_BIND_RETURN(TYPE, Type, type, lane_count, lane_type) \ | |
1993 assembler->Bind(&return_##type); \ | |
1994 { \ | |
1995 result_var.Bind(assembler->HeapConstant( \ | |
1996 assembler->isolate()->factory()->type##_string())); \ | |
1997 assembler->Goto(&return_result); \ | |
1998 } | |
1999 SIMD128_TYPES(SIMD128_BIND_RETURN) | |
2000 #undef SIMD128_BIND_RETURN | |
2001 | |
2002 assembler->Bind(&return_result); | |
2003 return result_var.value(); | |
2004 } | |
2005 | |
2006 // static | |
1885 compiler::Node* InstanceOfStub::Generate(CodeStubAssembler* assembler, | 2007 compiler::Node* InstanceOfStub::Generate(CodeStubAssembler* assembler, |
1886 compiler::Node* object, | 2008 compiler::Node* object, |
1887 compiler::Node* callable, | 2009 compiler::Node* callable, |
1888 compiler::Node* context) { | 2010 compiler::Node* context) { |
1889 typedef CodeStubAssembler::Label Label; | 2011 typedef CodeStubAssembler::Label Label; |
1890 typedef CodeStubAssembler::Variable Variable; | 2012 typedef CodeStubAssembler::Variable Variable; |
1891 | 2013 |
1892 Label return_runtime(assembler, Label::kDeferred), end(assembler); | 2014 Label return_runtime(assembler, Label::kDeferred), end(assembler); |
1893 Variable result(assembler, MachineRepresentation::kTagged); | 2015 Variable result(assembler, MachineRepresentation::kTagged); |
1894 | 2016 |
(...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4093 void ToObjectStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4215 void ToObjectStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
4094 descriptor->Initialize(Runtime::FunctionForId(Runtime::kToObject)->entry); | 4216 descriptor->Initialize(Runtime::FunctionForId(Runtime::kToObject)->entry); |
4095 descriptor->SetMissHandler(Runtime::kToObject); | 4217 descriptor->SetMissHandler(Runtime::kToObject); |
4096 } | 4218 } |
4097 | 4219 |
4098 void StoreTransitionStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4220 void StoreTransitionStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
4099 descriptor->Initialize( | 4221 descriptor->Initialize( |
4100 FUNCTION_ADDR(Runtime_TransitionStoreIC_MissFromStubFailure)); | 4222 FUNCTION_ADDR(Runtime_TransitionStoreIC_MissFromStubFailure)); |
4101 } | 4223 } |
4102 | 4224 |
4103 void TypeofStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | |
4104 descriptor->SetMissHandler(Runtime::kTypeof); | |
4105 } | |
4106 | |
4107 void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4225 void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
4108 descriptor->Initialize( | 4226 descriptor->Initialize( |
4109 Runtime::FunctionForId(Runtime::kNumberToString)->entry); | 4227 Runtime::FunctionForId(Runtime::kNumberToString)->entry); |
4110 descriptor->SetMissHandler(Runtime::kNumberToString); | 4228 descriptor->SetMissHandler(Runtime::kNumberToString); |
4111 } | 4229 } |
4112 | 4230 |
4113 | 4231 |
4114 void FastCloneRegExpStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4232 void FastCloneRegExpStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
4115 FastCloneRegExpDescriptor call_descriptor(isolate()); | 4233 FastCloneRegExpDescriptor call_descriptor(isolate()); |
4116 descriptor->Initialize( | 4234 descriptor->Initialize( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4183 } | 4301 } |
4184 | 4302 |
4185 | 4303 |
4186 void GrowArrayElementsStub::InitializeDescriptor( | 4304 void GrowArrayElementsStub::InitializeDescriptor( |
4187 CodeStubDescriptor* descriptor) { | 4305 CodeStubDescriptor* descriptor) { |
4188 descriptor->Initialize( | 4306 descriptor->Initialize( |
4189 Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); | 4307 Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); |
4190 } | 4308 } |
4191 | 4309 |
4192 | 4310 |
4193 void TypeofStub::GenerateAheadOfTime(Isolate* isolate) { | |
4194 TypeofStub stub(isolate); | |
4195 stub.GetCode(); | |
4196 } | |
4197 | |
4198 namespace { | 4311 namespace { |
4199 | 4312 |
4200 compiler::Node* GenerateHasProperty( | 4313 compiler::Node* GenerateHasProperty( |
4201 CodeStubAssembler* assembler, compiler::Node* object, compiler::Node* key, | 4314 CodeStubAssembler* assembler, compiler::Node* object, compiler::Node* key, |
4202 compiler::Node* context, Runtime::FunctionId fallback_runtime_function_id) { | 4315 compiler::Node* context, Runtime::FunctionId fallback_runtime_function_id) { |
4203 typedef compiler::Node Node; | 4316 typedef compiler::Node Node; |
4204 typedef CodeStubAssembler::Label Label; | 4317 typedef CodeStubAssembler::Label Label; |
4205 typedef CodeStubAssembler::Variable Variable; | 4318 typedef CodeStubAssembler::Variable Variable; |
4206 | 4319 |
4207 Label call_runtime(assembler, Label::kDeferred), return_true(assembler), | 4320 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())) { | 5045 if (type->Is(Type::UntaggedPointer())) { |
4933 return Representation::External(); | 5046 return Representation::External(); |
4934 } | 5047 } |
4935 | 5048 |
4936 DCHECK(!type->Is(Type::Untagged())); | 5049 DCHECK(!type->Is(Type::Untagged())); |
4937 return Representation::Tagged(); | 5050 return Representation::Tagged(); |
4938 } | 5051 } |
4939 | 5052 |
4940 } // namespace internal | 5053 } // namespace internal |
4941 } // namespace v8 | 5054 } // namespace v8 |
OLD | NEW |