OLD | NEW |
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 7746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7757 { | 7757 { |
7758 result.Bind( | 7758 result.Bind( |
7759 CallRuntime(fallback_runtime_function_id, context, object, key)); | 7759 CallRuntime(fallback_runtime_function_id, context, object, key)); |
7760 Goto(&end); | 7760 Goto(&end); |
7761 } | 7761 } |
7762 | 7762 |
7763 Bind(&end); | 7763 Bind(&end); |
7764 return result.value(); | 7764 return result.value(); |
7765 } | 7765 } |
7766 | 7766 |
| 7767 Node* CodeStubAssembler::ClassOf(Node* value) { |
| 7768 Variable var_result(this, MachineRepresentation::kTaggedPointer); |
| 7769 Label if_function(this, Label::kDeferred), if_object(this, Label::kDeferred), |
| 7770 if_primitive(this, Label::kDeferred), return_result(this); |
| 7771 |
| 7772 // Check if {value} is a Smi. |
| 7773 GotoIf(TaggedIsSmi(value), &if_primitive); |
| 7774 |
| 7775 Node* value_map = LoadMap(value); |
| 7776 Node* value_instance_type = LoadMapInstanceType(value_map); |
| 7777 |
| 7778 // Check if {value} is a JSFunction or JSBoundFunction. |
| 7779 STATIC_ASSERT(LAST_TYPE == LAST_FUNCTION_TYPE); |
| 7780 GotoIf(Uint32LessThanOrEqual(Int32Constant(FIRST_FUNCTION_TYPE), |
| 7781 value_instance_type), |
| 7782 &if_function); |
| 7783 |
| 7784 // Check if {value} is a primitive HeapObject. |
| 7785 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); |
| 7786 GotoIf(Uint32LessThan(value_instance_type, |
| 7787 Int32Constant(FIRST_JS_RECEIVER_TYPE)), |
| 7788 &if_primitive); |
| 7789 |
| 7790 // Load the {value}s constructor, and check that it's a JSFunction. |
| 7791 Node* constructor = LoadMapConstructor(value_map); |
| 7792 GotoUnless(IsJSFunction(constructor), &if_object); |
| 7793 |
| 7794 // Return the instance class name for the {constructor}. |
| 7795 Node* shared_info = |
| 7796 LoadObjectField(constructor, JSFunction::kSharedFunctionInfoOffset); |
| 7797 Node* instance_class_name = LoadObjectField( |
| 7798 shared_info, SharedFunctionInfo::kInstanceClassNameOffset); |
| 7799 var_result.Bind(instance_class_name); |
| 7800 Goto(&return_result); |
| 7801 |
| 7802 Bind(&if_function); |
| 7803 var_result.Bind(LoadRoot(Heap::kFunction_stringRootIndex)); |
| 7804 Goto(&return_result); |
| 7805 |
| 7806 Bind(&if_object); |
| 7807 var_result.Bind(LoadRoot(Heap::kObject_stringRootIndex)); |
| 7808 Goto(&return_result); |
| 7809 |
| 7810 Bind(&if_primitive); |
| 7811 var_result.Bind(NullConstant()); |
| 7812 Goto(&return_result); |
| 7813 |
| 7814 Bind(&return_result); |
| 7815 return var_result.value(); |
| 7816 } |
| 7817 |
7767 Node* CodeStubAssembler::Typeof(Node* value, Node* context) { | 7818 Node* CodeStubAssembler::Typeof(Node* value, Node* context) { |
7768 Variable result_var(this, MachineRepresentation::kTagged); | 7819 Variable result_var(this, MachineRepresentation::kTagged); |
7769 | 7820 |
7770 Label return_number(this, Label::kDeferred), if_oddball(this), | 7821 Label return_number(this, Label::kDeferred), if_oddball(this), |
7771 return_function(this), return_undefined(this), return_object(this), | 7822 return_function(this), return_undefined(this), return_object(this), |
7772 return_string(this), return_result(this); | 7823 return_string(this), return_result(this); |
7773 | 7824 |
7774 GotoIf(TaggedIsSmi(value), &return_number); | 7825 GotoIf(TaggedIsSmi(value), &return_number); |
7775 | 7826 |
7776 Node* map = LoadMap(value); | 7827 Node* map = LoadMap(value); |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8342 deferred_on_reject); | 8393 deferred_on_reject); |
8343 StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kDebugIdOffset, | 8394 StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kDebugIdOffset, |
8344 SmiConstant(kDebugPromiseNoID)); | 8395 SmiConstant(kDebugPromiseNoID)); |
8345 StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kContextOffset, | 8396 StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kContextOffset, |
8346 context); | 8397 context); |
8347 return result; | 8398 return result; |
8348 } | 8399 } |
8349 | 8400 |
8350 } // namespace internal | 8401 } // namespace internal |
8351 } // namespace v8 | 8402 } // namespace v8 |
OLD | NEW |