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

Side by Side Diff: src/code-stub-assembler.cc

Issue 2504553003: [es6] Perform the IsConstructor test in GetSuperConstructor. (Closed)
Patch Set: Fix IsNull call Created 4 years 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
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #include "src/code-stub-assembler.h" 4 #include "src/code-stub-assembler.h"
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/frames-inl.h" 6 #include "src/frames-inl.h"
7 #include "src/frames.h" 7 #include "src/frames.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 2838 matching lines...) Expand 10 before | Expand all | Expand 10 after
2849 Int32Constant(0)); 2849 Int32Constant(0));
2850 } 2850 }
2851 2851
2852 Node* CodeStubAssembler::IsCallableMap(Node* map) { 2852 Node* CodeStubAssembler::IsCallableMap(Node* map) {
2853 CSA_ASSERT(this, IsMap(map)); 2853 CSA_ASSERT(this, IsMap(map));
2854 return Word32NotEqual( 2854 return Word32NotEqual(
2855 Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsCallable)), 2855 Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsCallable)),
2856 Int32Constant(0)); 2856 Int32Constant(0));
2857 } 2857 }
2858 2858
2859 Node* CodeStubAssembler::IsConstructorMap(Node* map) {
2860 CSA_ASSERT(this, IsMap(map));
2861 return Word32NotEqual(
2862 Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsConstructor)),
2863 Int32Constant(0));
2864 }
2865
2859 Node* CodeStubAssembler::IsSpecialReceiverInstanceType(Node* instance_type) { 2866 Node* CodeStubAssembler::IsSpecialReceiverInstanceType(Node* instance_type) {
2860 STATIC_ASSERT(JS_GLOBAL_OBJECT_TYPE <= LAST_SPECIAL_RECEIVER_TYPE); 2867 STATIC_ASSERT(JS_GLOBAL_OBJECT_TYPE <= LAST_SPECIAL_RECEIVER_TYPE);
2861 return Int32LessThanOrEqual(instance_type, 2868 return Int32LessThanOrEqual(instance_type,
2862 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)); 2869 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE));
2863 } 2870 }
2864 2871
2865 Node* CodeStubAssembler::IsStringInstanceType(Node* instance_type) { 2872 Node* CodeStubAssembler::IsStringInstanceType(Node* instance_type) {
2866 STATIC_ASSERT(INTERNALIZED_STRING_TYPE == FIRST_TYPE); 2873 STATIC_ASSERT(INTERNALIZED_STRING_TYPE == FIRST_TYPE);
2867 return Int32LessThan(instance_type, Int32Constant(FIRST_NONSTRING_TYPE)); 2874 return Int32LessThan(instance_type, Int32Constant(FIRST_NONSTRING_TYPE));
2868 } 2875 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2929 2936
2930 Node* CodeStubAssembler::IsDictionary(Node* object) { 2937 Node* CodeStubAssembler::IsDictionary(Node* object) {
2931 return Word32Or(IsHashTable(object), IsUnseededNumberDictionary(object)); 2938 return Word32Or(IsHashTable(object), IsUnseededNumberDictionary(object));
2932 } 2939 }
2933 2940
2934 Node* CodeStubAssembler::IsUnseededNumberDictionary(Node* object) { 2941 Node* CodeStubAssembler::IsUnseededNumberDictionary(Node* object) {
2935 return WordEqual(LoadMap(object), 2942 return WordEqual(LoadMap(object),
2936 LoadRoot(Heap::kUnseededNumberDictionaryMapRootIndex)); 2943 LoadRoot(Heap::kUnseededNumberDictionaryMapRootIndex));
2937 } 2944 }
2938 2945
2946 Node* CodeStubAssembler::IsJSFunction(Node* object) {
2947 return HasInstanceType(object, JS_FUNCTION_TYPE);
2948 }
2949
2939 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { 2950 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) {
2940 CSA_ASSERT(this, IsString(string)); 2951 CSA_ASSERT(this, IsString(string));
2941 // Translate the {index} into a Word. 2952 // Translate the {index} into a Word.
2942 index = SmiToWord(index); 2953 index = SmiToWord(index);
2943 2954
2944 // We may need to loop in case of cons or sliced strings. 2955 // We may need to loop in case of cons or sliced strings.
2945 Variable var_index(this, MachineType::PointerRepresentation()); 2956 Variable var_index(this, MachineType::PointerRepresentation());
2946 Variable var_result(this, MachineRepresentation::kWord32); 2957 Variable var_result(this, MachineRepresentation::kWord32);
2947 Variable var_string(this, MachineRepresentation::kTagged); 2958 Variable var_string(this, MachineRepresentation::kTagged);
2948 Variable* loop_vars[] = {&var_index, &var_string}; 2959 Variable* loop_vars[] = {&var_index, &var_string};
(...skipping 4849 matching lines...) Expand 10 before | Expand all | Expand 10 after
7798 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \ 7809 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \
7799 Goto(&return_result); \ 7810 Goto(&return_result); \
7800 } 7811 }
7801 SIMD128_TYPES(SIMD128_BIND_RETURN) 7812 SIMD128_TYPES(SIMD128_BIND_RETURN)
7802 #undef SIMD128_BIND_RETURN 7813 #undef SIMD128_BIND_RETURN
7803 7814
7804 Bind(&return_result); 7815 Bind(&return_result);
7805 return result_var.value(); 7816 return result_var.value();
7806 } 7817 }
7807 7818
7819 Node* CodeStubAssembler::GetSuperConstructor(Node* active_function,
7820 Node* context) {
7821 CSA_ASSERT(this, IsJSFunction(active_function));
7822
7823 Label is_not_constructor(this, Label::kDeferred), out(this);
7824 Variable result(this, MachineRepresentation::kTagged);
7825
7826 Node* map = LoadMap(active_function);
7827 Node* prototype = LoadMapPrototype(map);
7828 Node* prototype_map = LoadMap(prototype);
7829 GotoUnless(IsConstructorMap(prototype_map), &is_not_constructor);
7830
7831 result.Bind(prototype);
7832 Goto(&out);
7833
7834 Bind(&is_not_constructor);
7835 {
7836 result.Bind(CallRuntime(Runtime::kThrowNotSuperConstructor, context,
7837 prototype, active_function));
7838 Goto(&out);
7839 }
7840
7841 Bind(&out);
7842 return result.value();
7843 }
7844
7808 Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable, 7845 Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable,
7809 Node* context) { 7846 Node* context) {
7810 Label return_runtime(this, Label::kDeferred), end(this); 7847 Label return_runtime(this, Label::kDeferred), end(this);
7811 Variable result(this, MachineRepresentation::kTagged); 7848 Variable result(this, MachineRepresentation::kTagged);
7812 7849
7813 // Check if no one installed @@hasInstance somewhere. 7850 // Check if no one installed @@hasInstance somewhere.
7814 GotoUnless( 7851 GotoUnless(
7815 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex), 7852 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex),
7816 PropertyCell::kValueOffset), 7853 PropertyCell::kValueOffset),
7817 SmiConstant(Smi::FromInt(Isolate::kProtectorValid))), 7854 SmiConstant(Smi::FromInt(Isolate::kProtectorValid))),
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
8241 8278
8242 void CodeStubAssembler::PromiseSet(Node* promise, Node* status, Node* result) { 8279 void CodeStubAssembler::PromiseSet(Node* promise, Node* status, Node* result) {
8243 CSA_ASSERT(this, TaggedIsSmi(status)); 8280 CSA_ASSERT(this, TaggedIsSmi(status));
8244 StoreObjectField(promise, JSPromise::kStatusOffset, status); 8281 StoreObjectField(promise, JSPromise::kStatusOffset, status);
8245 StoreObjectField(promise, JSPromise::kResultOffset, result); 8282 StoreObjectField(promise, JSPromise::kResultOffset, result);
8246 StoreObjectField(promise, JSPromise::kFlagsOffset, SmiConstant(0)); 8283 StoreObjectField(promise, JSPromise::kFlagsOffset, SmiConstant(0));
8247 } 8284 }
8248 8285
8249 } // namespace internal 8286 } // namespace internal
8250 } // namespace v8 8287 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698