Chromium Code Reviews| Index: src/code-stub-assembler.cc |
| diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc |
| index f87f55a479bdc9e3991f5dc48e26fc982b068168..756a5696e605c56aa8d304566623ca50dcdb06f2 100644 |
| --- a/src/code-stub-assembler.cc |
| +++ b/src/code-stub-assembler.cc |
| @@ -2229,6 +2229,34 @@ Node* CodeStubAssembler::ToThisValue(Node* context, Node* value, |
| return var_value.value(); |
| } |
| +Node* CodeStubAssembler::ThrowIfNotType(Node* context, Node* value, |
| + int instance_type, |
|
Igor Sheludko
2016/09/29 12:55:29
Same here.
jgruber
2016/09/29 14:40:27
Done.
|
| + char const* method_name) { |
| + Label out(this), throw_exception(this, Label::kDeferred); |
| + Variable var_value_map(this, MachineType::PointerRepresentation()); |
|
Igor Sheludko
2016/09/29 12:55:29
MachineRepresentation::kTagged
jgruber
2016/09/29 14:40:27
Done.
|
| + |
| + GotoIf(WordIsSmi(value), &throw_exception); |
| + |
| + // Load the instance type of the {value}. |
| + var_value_map.Bind(LoadMap(value)); |
| + Node* const value_instance_type = LoadMapInstanceType(var_value_map.value()); |
| + |
| + Branch(Word32Equal(value_instance_type, Int32Constant(instance_type)), &out, |
| + &throw_exception); |
| + |
| + // The {value} is not a compatible receiver for this method. |
| + Bind(&throw_exception); |
| + CallRuntime( |
| + Runtime::kThrowIncompatibleMethodReceiver, context, |
| + HeapConstant(factory()->NewStringFromAsciiChecked(method_name, TENURED)), |
| + value); |
| + var_value_map.Bind(UndefinedConstant()); |
| + Goto(&out); // Never reached. |
| + |
| + Bind(&out); |
| + return var_value_map.value(); |
| +} |
| + |
| Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { |
| // Translate the {index} into a Word. |
| index = SmiToWord(index); |
| @@ -2336,14 +2364,14 @@ Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { |
| Bind(&if_stringisexternal); |
| { |
| // Check if the {string} is a short external string. |
| - Label if_stringisshort(this), |
| - if_stringisnotshort(this, Label::kDeferred); |
| + Label if_stringisnotshort(this), |
|
Igor Sheludko
2016/09/29 12:55:29
I guess this renaming should be part of substr CL.
jgruber
2016/09/29 14:40:27
How come? It's unrelated to both - I'll just split
Igor Sheludko
2016/09/29 15:01:34
Ok.
|
| + if_stringisshort(this, Label::kDeferred); |
| Branch(Word32Equal(Word32And(string_instance_type, |
| Int32Constant(kShortExternalStringMask)), |
| Int32Constant(0)), |
| - &if_stringisshort, &if_stringisnotshort); |
| + &if_stringisnotshort, &if_stringisshort); |
| - Bind(&if_stringisshort); |
| + Bind(&if_stringisnotshort); |
| { |
| // Load the actual resource data from the {string}. |
| Node* string_resource_data = |
| @@ -2373,7 +2401,7 @@ Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { |
| } |
| } |
| - Bind(&if_stringisnotshort); |
| + Bind(&if_stringisshort); |
| { |
| // The {string} might be compressed, call the runtime. |
| var_result.Bind(SmiToWord32( |