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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "src/compiler/pipeline.h" | 7 #include "src/compiler/pipeline.h" |
8 #include "src/execution.h" | 8 #include "src/execution.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 #include "src/interpreter/bytecode-array-builder.h" | 10 #include "src/interpreter/bytecode-array-builder.h" |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 SNPrintF(script, "%s %s({});", snippets[i].code_snippet, kFunctionName); | 971 SNPrintF(script, "%s %s({});", snippets[i].code_snippet, kFunctionName); |
972 | 972 |
973 BytecodeGraphTester tester(isolate, zone, script.start()); | 973 BytecodeGraphTester tester(isolate, zone, script.start()); |
974 auto callable = tester.GetCallable<>(); | 974 auto callable = tester.GetCallable<>(); |
975 Handle<Object> return_value = callable().ToHandleChecked(); | 975 Handle<Object> return_value = callable().ToHandleChecked(); |
976 CHECK(return_value->SameValue(*snippets[i].return_value())); | 976 CHECK(return_value->SameValue(*snippets[i].return_value())); |
977 } | 977 } |
978 } | 978 } |
979 | 979 |
980 | 980 |
| 981 TEST(BytecodeGraphBuilderDeleteLookupSlot) { |
| 982 HandleAndZoneScope scope; |
| 983 Isolate* isolate = scope.main_isolate(); |
| 984 Zone* zone = scope.main_zone(); |
| 985 Factory* factory = isolate->factory(); |
| 986 |
| 987 // TODO(mythria): Add more tests when we have support for LdaLookupSlot. |
| 988 const char* function_prologue = "var f;" |
| 989 "var x = 1;" |
| 990 "y = 10;" |
| 991 "var obj = {val:10};" |
| 992 "var z = 30;" |
| 993 "function f1() {" |
| 994 " var z = 20;" |
| 995 " eval(\"function t() {"; |
| 996 const char* function_epilogue = " }; f = t; t();\");" |
| 997 "}" |
| 998 "f1();"; |
| 999 |
| 1000 ExpectedSnippet<0> snippets[] = { |
| 1001 {"return delete y;", {factory->true_value()}}, |
| 1002 {"return delete z;", {factory->false_value()}}, |
| 1003 }; |
| 1004 |
| 1005 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
| 1006 for (size_t i = 0; i < num_snippets; i++) { |
| 1007 ScopedVector<char> script(1024); |
| 1008 SNPrintF(script, "%s %s %s", function_prologue, snippets[i].code_snippet, |
| 1009 function_epilogue); |
| 1010 |
| 1011 BytecodeGraphTester tester(isolate, zone, script.start(), "t"); |
| 1012 auto callable = tester.GetCallable<>(); |
| 1013 Handle<Object> return_value = callable().ToHandleChecked(); |
| 1014 CHECK(return_value->SameValue(*snippets[i].return_value())); |
| 1015 } |
| 1016 } |
| 1017 |
| 1018 |
981 bool get_compare_result(Token::Value opcode, Handle<Object> lhs_value, | 1019 bool get_compare_result(Token::Value opcode, Handle<Object> lhs_value, |
982 Handle<Object> rhs_value) { | 1020 Handle<Object> rhs_value) { |
983 switch (opcode) { | 1021 switch (opcode) { |
984 case Token::Value::EQ: | 1022 case Token::Value::EQ: |
985 return Object::Equals(lhs_value, rhs_value).FromJust(); | 1023 return Object::Equals(lhs_value, rhs_value).FromJust(); |
986 case Token::Value::NE: | 1024 case Token::Value::NE: |
987 return !Object::Equals(lhs_value, rhs_value).FromJust(); | 1025 return !Object::Equals(lhs_value, rhs_value).FromJust(); |
988 case Token::Value::EQ_STRICT: | 1026 case Token::Value::EQ_STRICT: |
989 return lhs_value->StrictEquals(*rhs_value); | 1027 return lhs_value->StrictEquals(*rhs_value); |
990 case Token::Value::NE_STRICT: | 1028 case Token::Value::NE_STRICT: |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 BytecodeGraphTester tester(isolate, zone, script.start()); | 1914 BytecodeGraphTester tester(isolate, zone, script.start()); |
1877 auto callable = tester.GetCallable<>(); | 1915 auto callable = tester.GetCallable<>(); |
1878 Handle<Object> return_value = callable().ToHandleChecked(); | 1916 Handle<Object> return_value = callable().ToHandleChecked(); |
1879 CHECK(return_value->SameValue(*snippets[i].return_value())); | 1917 CHECK(return_value->SameValue(*snippets[i].return_value())); |
1880 } | 1918 } |
1881 } | 1919 } |
1882 | 1920 |
1883 } // namespace compiler | 1921 } // namespace compiler |
1884 } // namespace internal | 1922 } // namespace internal |
1885 } // namespace v8 | 1923 } // namespace v8 |
OLD | NEW |