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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/execution.h" | 7 #include "src/execution.h" |
8 #include "src/handles.h" | 8 #include "src/handles.h" |
9 #include "src/interpreter/bytecode-array-builder.h" | 9 #include "src/interpreter/bytecode-array-builder.h" |
10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
(...skipping 3907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3918 {"var method = 'f';" | 3918 {"var method = 'f';" |
3919 "class C {\n" | 3919 "class C {\n" |
3920 " [method]() { return 106; }\n" | 3920 " [method]() { return 106; }\n" |
3921 "}\n" | 3921 "}\n" |
3922 "return new C().f();", | 3922 "return new C().f();", |
3923 handle(Smi::FromInt(106), isolate)}, | 3923 handle(Smi::FromInt(106), isolate)}, |
3924 }; | 3924 }; |
3925 | 3925 |
3926 for (size_t i = 0; i < arraysize(examples); ++i) { | 3926 for (size_t i = 0; i < arraysize(examples); ++i) { |
3927 std::string source(InterpreterTester::SourceForBody(examples[i].first)); | 3927 std::string source(InterpreterTester::SourceForBody(examples[i].first)); |
3928 InterpreterTester tester(handles.main_isolate(), source.c_str()); | 3928 InterpreterTester tester(handles.main_isolate(), source.c_str(), "*"); |
3929 auto callable = tester.GetCallable<>(); | 3929 auto callable = tester.GetCallable<>(); |
3930 | 3930 |
3931 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3931 Handle<i::Object> return_value = callable().ToHandleChecked(); |
3932 CHECK(return_value->SameValue(*examples[i].second)); | 3932 CHECK(return_value->SameValue(*examples[i].second)); |
3933 } | 3933 } |
3934 } | 3934 } |
3935 | 3935 |
3936 TEST(InterpreterClassAndSuperClass) { | 3936 TEST(InterpreterClassAndSuperClass) { |
3937 HandleAndZoneScope handles; | 3937 HandleAndZoneScope handles; |
3938 i::Isolate* isolate = handles.main_isolate(); | 3938 i::Isolate* isolate = handles.main_isolate(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3978 "return new B().method();\n", | 3978 "return new B().method();\n", |
3979 handle(Smi::FromInt(1), isolate)}, | 3979 handle(Smi::FromInt(1), isolate)}, |
3980 {"var object = { setY(v) { super.y = v; }};\n" | 3980 {"var object = { setY(v) { super.y = v; }};\n" |
3981 "object.setY(10);\n" | 3981 "object.setY(10);\n" |
3982 "return object.y;\n", | 3982 "return object.y;\n", |
3983 handle(Smi::FromInt(10), isolate)}, | 3983 handle(Smi::FromInt(10), isolate)}, |
3984 }; | 3984 }; |
3985 | 3985 |
3986 for (size_t i = 0; i < arraysize(examples); ++i) { | 3986 for (size_t i = 0; i < arraysize(examples); ++i) { |
3987 std::string source(InterpreterTester::SourceForBody(examples[i].first)); | 3987 std::string source(InterpreterTester::SourceForBody(examples[i].first)); |
3988 InterpreterTester tester(handles.main_isolate(), source.c_str()); | 3988 InterpreterTester tester(handles.main_isolate(), source.c_str(), "*"); |
3989 auto callable = tester.GetCallable<>(); | 3989 auto callable = tester.GetCallable<>(); |
3990 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3990 Handle<i::Object> return_value = callable().ToHandleChecked(); |
3991 CHECK(return_value->SameValue(*examples[i].second)); | 3991 CHECK(return_value->SameValue(*examples[i].second)); |
3992 } | 3992 } |
3993 } | 3993 } |
3994 | 3994 |
3995 TEST(InterpreterConstDeclaration) { | 3995 TEST(InterpreterConstDeclaration) { |
3996 HandleAndZoneScope handles; | 3996 HandleAndZoneScope handles; |
3997 i::Isolate* isolate = handles.main_isolate(); | 3997 i::Isolate* isolate = handles.main_isolate(); |
3998 i::Factory* factory = isolate->factory(); | 3998 i::Factory* factory = isolate->factory(); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4226 Handle<i::Object> return_value = callable().ToHandleChecked(); | 4226 Handle<i::Object> return_value = callable().ToHandleChecked(); |
4227 CHECK(return_value->SameValue(*const_decl[i].second)); | 4227 CHECK(return_value->SameValue(*const_decl[i].second)); |
4228 } | 4228 } |
4229 | 4229 |
4230 FLAG_legacy_const = old_flag_legacy_const; | 4230 FLAG_legacy_const = old_flag_legacy_const; |
4231 } | 4231 } |
4232 | 4232 |
4233 } // namespace interpreter | 4233 } // namespace interpreter |
4234 } // namespace internal | 4234 } // namespace internal |
4235 } // namespace v8 | 4235 } // namespace v8 |
OLD | NEW |