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 #include "src/ic/handler-configuration.h" | 8 #include "src/ic/handler-configuration.h" |
9 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
10 | 10 |
(...skipping 2551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 STATIC_ASSERT(INTERNALIZED_STRING_TYPE == FIRST_TYPE); | 2562 STATIC_ASSERT(INTERNALIZED_STRING_TYPE == FIRST_TYPE); |
2563 return Int32LessThan(instance_type, Int32Constant(FIRST_NONSTRING_TYPE)); | 2563 return Int32LessThan(instance_type, Int32Constant(FIRST_NONSTRING_TYPE)); |
2564 } | 2564 } |
2565 | 2565 |
2566 Node* CodeStubAssembler::IsJSReceiverInstanceType(Node* instance_type) { | 2566 Node* CodeStubAssembler::IsJSReceiverInstanceType(Node* instance_type) { |
2567 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); | 2567 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
2568 return Int32GreaterThanOrEqual(instance_type, | 2568 return Int32GreaterThanOrEqual(instance_type, |
2569 Int32Constant(FIRST_JS_RECEIVER_TYPE)); | 2569 Int32Constant(FIRST_JS_RECEIVER_TYPE)); |
2570 } | 2570 } |
2571 | 2571 |
| 2572 Node* CodeStubAssembler::IsCallableMap(Node* map) { |
| 2573 return Word32NotEqual( |
| 2574 Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsCallable)), |
| 2575 Int32Constant(0)); |
| 2576 } |
| 2577 |
2572 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { | 2578 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { |
2573 // Translate the {index} into a Word. | 2579 // Translate the {index} into a Word. |
2574 index = SmiToWord(index); | 2580 index = SmiToWord(index); |
2575 | 2581 |
2576 // We may need to loop in case of cons or sliced strings. | 2582 // We may need to loop in case of cons or sliced strings. |
2577 Variable var_index(this, MachineType::PointerRepresentation()); | 2583 Variable var_index(this, MachineType::PointerRepresentation()); |
2578 Variable var_result(this, MachineRepresentation::kWord32); | 2584 Variable var_result(this, MachineRepresentation::kWord32); |
2579 Variable var_string(this, MachineRepresentation::kTagged); | 2585 Variable var_string(this, MachineRepresentation::kTagged); |
2580 Variable* loop_vars[] = {&var_index, &var_string}; | 2586 Variable* loop_vars[] = {&var_index, &var_string}; |
2581 Label done_loop(this, &var_result), loop(this, 2, loop_vars); | 2587 Label done_loop(this, &var_result), loop(this, 2, loop_vars); |
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4288 Node* getter = LoadObjectField(accessor_pair, AccessorPair::kGetterOffset); | 4294 Node* getter = LoadObjectField(accessor_pair, AccessorPair::kGetterOffset); |
4289 Node* getter_map = LoadMap(getter); | 4295 Node* getter_map = LoadMap(getter); |
4290 Node* instance_type = LoadMapInstanceType(getter_map); | 4296 Node* instance_type = LoadMapInstanceType(getter_map); |
4291 // FunctionTemplateInfo getters are not supported yet. | 4297 // FunctionTemplateInfo getters are not supported yet. |
4292 GotoIf( | 4298 GotoIf( |
4293 Word32Equal(instance_type, Int32Constant(FUNCTION_TEMPLATE_INFO_TYPE)), | 4299 Word32Equal(instance_type, Int32Constant(FUNCTION_TEMPLATE_INFO_TYPE)), |
4294 if_bailout); | 4300 if_bailout); |
4295 | 4301 |
4296 // Return undefined if the {getter} is not callable. | 4302 // Return undefined if the {getter} is not callable. |
4297 var_value.Bind(UndefinedConstant()); | 4303 var_value.Bind(UndefinedConstant()); |
4298 GotoIf(Word32Equal(Word32And(LoadMapBitField(getter_map), | 4304 GotoUnless(IsCallableMap(getter_map), &done); |
4299 Int32Constant(1 << Map::kIsCallable)), | |
4300 Int32Constant(0)), | |
4301 &done); | |
4302 | 4305 |
4303 // Call the accessor. | 4306 // Call the accessor. |
4304 Callable callable = CodeFactory::Call(isolate()); | 4307 Callable callable = CodeFactory::Call(isolate()); |
4305 Node* result = CallJS(callable, context, getter, receiver); | 4308 Node* result = CallJS(callable, context, getter, receiver); |
4306 var_value.Bind(result); | 4309 var_value.Bind(result); |
4307 Goto(&done); | 4310 Goto(&done); |
4308 } | 4311 } |
4309 | 4312 |
4310 Bind(&done); | 4313 Bind(&done); |
4311 return var_value.value(); | 4314 return var_value.value(); |
(...skipping 3777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8089 | 8092 |
8090 // Check if no one installed @@hasInstance somewhere. | 8093 // Check if no one installed @@hasInstance somewhere. |
8091 GotoUnless( | 8094 GotoUnless( |
8092 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex), | 8095 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex), |
8093 PropertyCell::kValueOffset), | 8096 PropertyCell::kValueOffset), |
8094 SmiConstant(Smi::FromInt(Isolate::kArrayProtectorValid))), | 8097 SmiConstant(Smi::FromInt(Isolate::kArrayProtectorValid))), |
8095 &return_runtime); | 8098 &return_runtime); |
8096 | 8099 |
8097 // Check if {callable} is a valid receiver. | 8100 // Check if {callable} is a valid receiver. |
8098 GotoIf(TaggedIsSmi(callable), &return_runtime); | 8101 GotoIf(TaggedIsSmi(callable), &return_runtime); |
8099 GotoIf(Word32Equal(Word32And(LoadMapBitField(LoadMap(callable)), | 8102 GotoUnless(IsCallableMap(LoadMap(callable)), &return_runtime); |
8100 Int32Constant(1 << Map::kIsCallable)), | |
8101 Int32Constant(0)), | |
8102 &return_runtime); | |
8103 | 8103 |
8104 // Use the inline OrdinaryHasInstance directly. | 8104 // Use the inline OrdinaryHasInstance directly. |
8105 result.Bind(OrdinaryHasInstance(context, callable, object)); | 8105 result.Bind(OrdinaryHasInstance(context, callable, object)); |
8106 Goto(&end); | 8106 Goto(&end); |
8107 | 8107 |
8108 // TODO(bmeurer): Use GetPropertyStub here once available. | 8108 // TODO(bmeurer): Use GetPropertyStub here once available. |
8109 Bind(&return_runtime); | 8109 Bind(&return_runtime); |
8110 { | 8110 { |
8111 result.Bind(CallRuntime(Runtime::kInstanceOf, context, object, callable)); | 8111 result.Bind(CallRuntime(Runtime::kInstanceOf, context, object, callable)); |
8112 Goto(&end); | 8112 Goto(&end); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8333 Node* buffer_bit_field = LoadObjectField( | 8333 Node* buffer_bit_field = LoadObjectField( |
8334 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); | 8334 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); |
8335 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); | 8335 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); |
8336 | 8336 |
8337 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask), | 8337 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask), |
8338 Int32Constant(0)); | 8338 Int32Constant(0)); |
8339 } | 8339 } |
8340 | 8340 |
8341 } // namespace internal | 8341 } // namespace internal |
8342 } // namespace v8 | 8342 } // namespace v8 |
OLD | NEW |