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 // TODO(rmcilroy): Remove this define after this flag is turned on globally | 5 // TODO(rmcilroy): Remove this define after this flag is turned on globally |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 // Check with no args. | 992 // Check with no args. |
993 { | 993 { |
994 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 994 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
995 builder.set_locals_count(1); | 995 builder.set_locals_count(1); |
996 builder.set_context_count(0); | 996 builder.set_context_count(0); |
997 builder.set_parameter_count(1); | 997 builder.set_parameter_count(1); |
998 size_t name_index = builder.GetConstantPoolEntry(name); | 998 size_t name_index = builder.GetConstantPoolEntry(name); |
999 builder.LoadNamedProperty(builder.Parameter(0), name_index, slot_index, | 999 builder.LoadNamedProperty(builder.Parameter(0), name_index, slot_index, |
1000 i::SLOPPY) | 1000 i::SLOPPY) |
1001 .StoreAccumulatorInRegister(Register(0)) | 1001 .StoreAccumulatorInRegister(Register(0)) |
1002 .Call(Register(0), builder.Parameter(0), 0) | 1002 .Call(Register(0), builder.Parameter(0), 0, 0) |
1003 .Return(); | 1003 .Return(); |
1004 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1004 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
1005 | 1005 |
1006 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 1006 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
1007 auto callable = tester.GetCallable<Handle<Object>>(); | 1007 auto callable = tester.GetCallable<Handle<Object>>(); |
1008 | 1008 |
1009 Handle<Object> object = InterpreterTester::NewObject( | 1009 Handle<Object> object = InterpreterTester::NewObject( |
1010 "new (function Obj() { this.func = function() { return 0x265; }})()"); | 1010 "new (function Obj() { this.func = function() { return 0x265; }})()"); |
1011 Handle<Object> return_val = callable(object).ToHandleChecked(); | 1011 Handle<Object> return_val = callable(object).ToHandleChecked(); |
1012 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x265)); | 1012 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x265)); |
1013 } | 1013 } |
1014 | 1014 |
1015 // Check that receiver is passed properly. | 1015 // Check that receiver is passed properly. |
1016 { | 1016 { |
1017 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 1017 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
1018 builder.set_locals_count(1); | 1018 builder.set_locals_count(1); |
1019 builder.set_context_count(0); | 1019 builder.set_context_count(0); |
1020 builder.set_parameter_count(1); | 1020 builder.set_parameter_count(1); |
1021 size_t name_index = builder.GetConstantPoolEntry(name); | 1021 size_t name_index = builder.GetConstantPoolEntry(name); |
1022 builder.LoadNamedProperty(builder.Parameter(0), name_index, slot_index, | 1022 builder.LoadNamedProperty(builder.Parameter(0), name_index, slot_index, |
1023 i::SLOPPY) | 1023 i::SLOPPY) |
1024 .StoreAccumulatorInRegister(Register(0)) | 1024 .StoreAccumulatorInRegister(Register(0)) |
1025 .Call(Register(0), builder.Parameter(0), 0) | 1025 .Call(Register(0), builder.Parameter(0), 0, 0) |
1026 .Return(); | 1026 .Return(); |
1027 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1027 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
1028 | 1028 |
1029 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 1029 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
1030 auto callable = tester.GetCallable<Handle<Object>>(); | 1030 auto callable = tester.GetCallable<Handle<Object>>(); |
1031 | 1031 |
1032 Handle<Object> object = InterpreterTester::NewObject( | 1032 Handle<Object> object = InterpreterTester::NewObject( |
1033 "new (function Obj() {" | 1033 "new (function Obj() {" |
1034 " this.val = 1234;" | 1034 " this.val = 1234;" |
1035 " this.func = function() { return this.val; };" | 1035 " this.func = function() { return this.val; };" |
(...skipping 11 matching lines...) Expand all Loading... |
1047 size_t name_index = builder.GetConstantPoolEntry(name); | 1047 size_t name_index = builder.GetConstantPoolEntry(name); |
1048 builder.LoadNamedProperty(builder.Parameter(0), name_index, slot_index, | 1048 builder.LoadNamedProperty(builder.Parameter(0), name_index, slot_index, |
1049 i::SLOPPY) | 1049 i::SLOPPY) |
1050 .StoreAccumulatorInRegister(Register(0)) | 1050 .StoreAccumulatorInRegister(Register(0)) |
1051 .LoadAccumulatorWithRegister(builder.Parameter(0)) | 1051 .LoadAccumulatorWithRegister(builder.Parameter(0)) |
1052 .StoreAccumulatorInRegister(Register(1)) | 1052 .StoreAccumulatorInRegister(Register(1)) |
1053 .LoadLiteral(Smi::FromInt(51)) | 1053 .LoadLiteral(Smi::FromInt(51)) |
1054 .StoreAccumulatorInRegister(Register(2)) | 1054 .StoreAccumulatorInRegister(Register(2)) |
1055 .LoadLiteral(Smi::FromInt(11)) | 1055 .LoadLiteral(Smi::FromInt(11)) |
1056 .StoreAccumulatorInRegister(Register(3)) | 1056 .StoreAccumulatorInRegister(Register(3)) |
1057 .Call(Register(0), Register(1), 2) | 1057 .Call(Register(0), Register(1), 2, 0) |
1058 .Return(); | 1058 .Return(); |
1059 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1059 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
1060 | 1060 |
1061 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 1061 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
1062 auto callable = tester.GetCallable<Handle<Object>>(); | 1062 auto callable = tester.GetCallable<Handle<Object>>(); |
1063 | 1063 |
1064 Handle<Object> object = InterpreterTester::NewObject( | 1064 Handle<Object> object = InterpreterTester::NewObject( |
1065 "new (function Obj() { " | 1065 "new (function Obj() { " |
1066 " this.func = function(a, b) { return a - b; }" | 1066 " this.func = function(a, b) { return a - b; }" |
1067 "})()"); | 1067 "})()"); |
(...skipping 26 matching lines...) Expand all Loading... |
1094 .LoadLiteral(factory->NewStringFromAsciiChecked("f")) | 1094 .LoadLiteral(factory->NewStringFromAsciiChecked("f")) |
1095 .StoreAccumulatorInRegister(Register(7)) | 1095 .StoreAccumulatorInRegister(Register(7)) |
1096 .LoadLiteral(factory->NewStringFromAsciiChecked("g")) | 1096 .LoadLiteral(factory->NewStringFromAsciiChecked("g")) |
1097 .StoreAccumulatorInRegister(Register(8)) | 1097 .StoreAccumulatorInRegister(Register(8)) |
1098 .LoadLiteral(factory->NewStringFromAsciiChecked("h")) | 1098 .LoadLiteral(factory->NewStringFromAsciiChecked("h")) |
1099 .StoreAccumulatorInRegister(Register(9)) | 1099 .StoreAccumulatorInRegister(Register(9)) |
1100 .LoadLiteral(factory->NewStringFromAsciiChecked("i")) | 1100 .LoadLiteral(factory->NewStringFromAsciiChecked("i")) |
1101 .StoreAccumulatorInRegister(Register(10)) | 1101 .StoreAccumulatorInRegister(Register(10)) |
1102 .LoadLiteral(factory->NewStringFromAsciiChecked("j")) | 1102 .LoadLiteral(factory->NewStringFromAsciiChecked("j")) |
1103 .StoreAccumulatorInRegister(Register(11)) | 1103 .StoreAccumulatorInRegister(Register(11)) |
1104 .Call(Register(0), Register(1), 10) | 1104 .Call(Register(0), Register(1), 10, 0) |
1105 .Return(); | 1105 .Return(); |
1106 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1106 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
1107 | 1107 |
1108 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 1108 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
1109 auto callable = tester.GetCallable<Handle<Object>>(); | 1109 auto callable = tester.GetCallable<Handle<Object>>(); |
1110 | 1110 |
1111 Handle<Object> object = InterpreterTester::NewObject( | 1111 Handle<Object> object = InterpreterTester::NewObject( |
1112 "new (function Obj() { " | 1112 "new (function Obj() { " |
1113 " this.prefix = \"prefix_\";" | 1113 " this.prefix = \"prefix_\";" |
1114 " this.func = function(a, b, c, d, e, f, g, h, i, j) {" | 1114 " this.func = function(a, b, c, d, e, f, g, h, i, j) {" |
(...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2947 callable().ToHandleChecked(); | 2947 callable().ToHandleChecked(); |
2948 | 2948 |
2949 Handle<Object> new_target_name = v8::Utils::OpenHandle( | 2949 Handle<Object> new_target_name = v8::Utils::OpenHandle( |
2950 *CompileRun("(function() { return (new f()).a.name; })();")); | 2950 *CompileRun("(function() { return (new f()).a.name; })();")); |
2951 CHECK(new_target_name->SameValue(*factory->NewStringFromStaticChars("f"))); | 2951 CHECK(new_target_name->SameValue(*factory->NewStringFromStaticChars("f"))); |
2952 } | 2952 } |
2953 | 2953 |
2954 } // namespace interpreter | 2954 } // namespace interpreter |
2955 } // namespace internal | 2955 } // namespace internal |
2956 } // namespace v8 | 2956 } // namespace v8 |
OLD | NEW |