OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/interpreter.h" | 5 #include "src/interpreter/interpreter.h" |
6 | 6 |
7 #include <fstream> | 7 #include <fstream> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1861 Node* closure = __ LoadRegister(Register::function_closure()); | 1861 Node* closure = __ LoadRegister(Register::function_closure()); |
1862 Node* context = __ GetContext(); | 1862 Node* context = __ GetContext(); |
1863 Node* result = FastCloneRegExpStub::Generate( | 1863 Node* result = FastCloneRegExpStub::Generate( |
1864 assembler, closure, literal_index, pattern, flags, context); | 1864 assembler, closure, literal_index, pattern, flags, context); |
1865 __ SetAccumulator(result); | 1865 __ SetAccumulator(result); |
1866 __ Dispatch(); | 1866 __ Dispatch(); |
1867 } | 1867 } |
1868 | 1868 |
1869 // CreateArrayLiteral <element_idx> <literal_idx> <flags> | 1869 // CreateArrayLiteral <element_idx> <literal_idx> <flags> |
1870 // | 1870 // |
1871 // Creates an array literal for literal index <literal_idx> with flags <flags> | 1871 // Creates an array literal for literal index <literal_idx> with |
1872 // and constant elements in <element_idx>. | 1872 // CreateArrayLiteral flags <flags> and constant elements in <element_idx>. |
1873 void Interpreter::DoCreateArrayLiteral(InterpreterAssembler* assembler) { | 1873 void Interpreter::DoCreateArrayLiteral(InterpreterAssembler* assembler) { |
1874 Node* index = __ BytecodeOperandIdx(0); | |
1875 Node* constant_elements = __ LoadConstantPoolEntry(index); | |
1876 Node* literal_index_raw = __ BytecodeOperandIdx(1); | 1874 Node* literal_index_raw = __ BytecodeOperandIdx(1); |
1877 Node* literal_index = __ SmiTag(literal_index_raw); | 1875 Node* literal_index = __ SmiTag(literal_index_raw); |
1878 Node* flags_raw = __ BytecodeOperandFlag(2); | 1876 Node* bytecode_flags = __ BytecodeOperandFlag(2); |
1879 Node* flags = __ SmiTag(flags_raw); | |
1880 Node* closure = __ LoadRegister(Register::function_closure()); | 1877 Node* closure = __ LoadRegister(Register::function_closure()); |
1881 Node* context = __ GetContext(); | 1878 Node* context = __ GetContext(); |
1882 Node* result = __ CallRuntime(Runtime::kCreateArrayLiteral, context, closure, | 1879 |
1883 literal_index, constant_elements, flags); | 1880 Variable result(assembler, MachineRepresentation::kTagged); |
1884 __ SetAccumulator(result); | 1881 Label fast_shallow_clone(assembler), |
1882 call_runtime(assembler, Label::kDeferred), dispatch(assembler); | |
1883 Node* must_create_with_runtime = | |
1884 __ BitFieldDecode<CreateArrayLiteralFlags::MustUseRuntimeBit>( | |
rmcilroy
2016/09/16 08:52:26
Last time I looked this emitted quite a few instru
klaasb
2016/09/19 13:53:58
It still seems to emit a bunch of code (bytecode_f
Michael Starzinger
2016/09/19 15:15:16
This looks dangerous to me. The version that corre
epertoso
2016/09/20 11:54:33
edi gets copied to esi to avoid modifying its valu
klaasb
2016/09/20 18:01:28
Thanks for the explanation Enrico!
| |
1885 bytecode_flags); | |
1886 __ BranchIf(must_create_with_runtime, &call_runtime, &fast_shallow_clone); | |
1887 | |
1888 __ Bind(&fast_shallow_clone); | |
1889 { | |
1890 DCHECK(FLAG_allocation_site_pretenuring); | |
1891 result.Bind(FastCloneShallowArrayStub::Generate( | |
1892 assembler, closure, literal_index, context, TRACK_ALLOCATION_SITE, | |
1893 &call_runtime)); | |
1894 __ Goto(&dispatch); | |
rmcilroy
2016/09/16 08:52:26
do the dispatch inline for both of these branches
klaasb
2016/09/19 13:53:58
Done.
| |
1895 } | |
1896 | |
1897 __ Bind(&call_runtime); | |
1898 { | |
1899 STATIC_ASSERT(CreateArrayLiteralFlags::FlagsBits::kShift == 0); | |
1900 Node* flags_raw = __ Word32And( | |
1901 bytecode_flags, | |
1902 __ Int32Constant(CreateArrayLiteralFlags::FlagsBits::kMask)); | |
1903 Node* flags = __ SmiTag(flags_raw); | |
1904 Node* index = __ BytecodeOperandIdx(0); | |
1905 Node* constant_elements = __ LoadConstantPoolEntry(index); | |
rmcilroy
2016/09/16 08:52:26
Hmm, it's interesting that the runtime call needs
klaasb
2016/09/19 13:53:58
Acknowledged.
| |
1906 result.Bind(__ CallRuntime(Runtime::kCreateArrayLiteral, context, closure, | |
1907 literal_index, constant_elements, flags)); | |
1908 __ Goto(&dispatch); | |
1909 } | |
1910 | |
1911 __ Bind(&dispatch); | |
1912 __ SetAccumulator(result.value()); | |
1885 __ Dispatch(); | 1913 __ Dispatch(); |
1886 } | 1914 } |
1887 | 1915 |
1888 // CreateObjectLiteral <element_idx> <literal_idx> <flags> | 1916 // CreateObjectLiteral <element_idx> <literal_idx> <flags> |
1889 // | 1917 // |
1890 // Creates an object literal for literal index <literal_idx> with | 1918 // Creates an object literal for literal index <literal_idx> with |
1891 // CreateObjectLiteralFlags <flags> and constant elements in <element_idx>. | 1919 // CreateObjectLiteralFlags <flags> and constant elements in <element_idx>. |
1892 void Interpreter::DoCreateObjectLiteral(InterpreterAssembler* assembler) { | 1920 void Interpreter::DoCreateObjectLiteral(InterpreterAssembler* assembler) { |
1893 Node* literal_index_raw = __ BytecodeOperandIdx(1); | 1921 Node* literal_index_raw = __ BytecodeOperandIdx(1); |
1894 Node* literal_index = __ SmiTag(literal_index_raw); | 1922 Node* literal_index = __ SmiTag(literal_index_raw); |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2456 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2484 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
2457 __ SmiTag(new_state)); | 2485 __ SmiTag(new_state)); |
2458 __ SetAccumulator(old_state); | 2486 __ SetAccumulator(old_state); |
2459 | 2487 |
2460 __ Dispatch(); | 2488 __ Dispatch(); |
2461 } | 2489 } |
2462 | 2490 |
2463 } // namespace interpreter | 2491 } // namespace interpreter |
2464 } // namespace internal | 2492 } // namespace internal |
2465 } // namespace v8 | 2493 } // namespace v8 |
OLD | NEW |