| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
| 7 | 7 |
| 8 #include "src/compiler/code-generator.h" | 8 #include "src/compiler/code-generator.h" |
| 9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 return BailoutId(-1); | 162 return BailoutId(-1); |
| 163 } | 163 } |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 | 166 |
| 167 TEST(TurboTrivialDeoptCodegen) { | 167 TEST(TurboTrivialDeoptCodegen) { |
| 168 HandleAndZoneScope scope; | 168 HandleAndZoneScope scope; |
| 169 InitializedHandleScope handles; | 169 InitializedHandleScope handles; |
| 170 | 170 |
| 171 FLAG_allow_natives_syntax = true; | 171 FLAG_allow_natives_syntax = true; |
| 172 FLAG_turbo_deoptimization = true; | |
| 173 | 172 |
| 174 TrivialDeoptCodegenTester t(&scope); | 173 TrivialDeoptCodegenTester t(&scope); |
| 175 t.GenerateCode(); | 174 t.GenerateCode(); |
| 176 | 175 |
| 177 DeoptimizationInputData* data = | 176 DeoptimizationInputData* data = |
| 178 DeoptimizationInputData::cast(t.result_code->deoptimization_data()); | 177 DeoptimizationInputData::cast(t.result_code->deoptimization_data()); |
| 179 | 178 |
| 180 // TODO(jarin) Find a way to test the safepoint. | 179 // TODO(jarin) Find a way to test the safepoint. |
| 181 | 180 |
| 182 // Check that we deoptimize to the right AST id. | 181 // Check that we deoptimize to the right AST id. |
| 183 CHECK_EQ(1, data->DeoptCount()); | 182 CHECK_EQ(1, data->DeoptCount()); |
| 184 CHECK_EQ(t.bailout_id.ToInt(), data->AstId(0).ToInt()); | 183 CHECK_EQ(t.bailout_id.ToInt(), data->AstId(0).ToInt()); |
| 185 } | 184 } |
| 186 | 185 |
| 187 | 186 |
| 188 TEST(TurboTrivialDeoptCodegenAndRun) { | 187 TEST(TurboTrivialDeoptCodegenAndRun) { |
| 189 HandleAndZoneScope scope; | 188 HandleAndZoneScope scope; |
| 190 InitializedHandleScope handles; | 189 InitializedHandleScope handles; |
| 191 | 190 |
| 192 FLAG_allow_natives_syntax = true; | 191 FLAG_allow_natives_syntax = true; |
| 193 FLAG_turbo_deoptimization = true; | |
| 194 | 192 |
| 195 TrivialDeoptCodegenTester t(&scope); | 193 TrivialDeoptCodegenTester t(&scope); |
| 196 t.GenerateCode(); | 194 t.GenerateCode(); |
| 197 | 195 |
| 198 t.function->ReplaceCode(*t.result_code); | 196 t.function->ReplaceCode(*t.result_code); |
| 199 t.info.context()->native_context()->AddOptimizedCode(*t.result_code); | 197 t.info.context()->native_context()->AddOptimizedCode(*t.result_code); |
| 200 | 198 |
| 201 Isolate* isolate = scope.main_isolate(); | 199 Isolate* isolate = scope.main_isolate(); |
| 202 Handle<Object> result; | 200 Handle<Object> result; |
| 203 bool has_pending_exception = | 201 bool has_pending_exception = |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 return BailoutId(-1); | 273 return BailoutId(-1); |
| 276 } | 274 } |
| 277 }; | 275 }; |
| 278 | 276 |
| 279 | 277 |
| 280 TEST(TurboTrivialRuntimeDeoptCodegenAndRun) { | 278 TEST(TurboTrivialRuntimeDeoptCodegenAndRun) { |
| 281 HandleAndZoneScope scope; | 279 HandleAndZoneScope scope; |
| 282 InitializedHandleScope handles; | 280 InitializedHandleScope handles; |
| 283 | 281 |
| 284 FLAG_allow_natives_syntax = true; | 282 FLAG_allow_natives_syntax = true; |
| 285 FLAG_turbo_deoptimization = true; | |
| 286 | 283 |
| 287 TrivialRuntimeDeoptCodegenTester t(&scope); | 284 TrivialRuntimeDeoptCodegenTester t(&scope); |
| 288 t.GenerateCode(); | 285 t.GenerateCode(); |
| 289 | 286 |
| 290 t.function->ReplaceCode(*t.result_code); | 287 t.function->ReplaceCode(*t.result_code); |
| 291 t.info.context()->native_context()->AddOptimizedCode(*t.result_code); | 288 t.info.context()->native_context()->AddOptimizedCode(*t.result_code); |
| 292 | 289 |
| 293 Isolate* isolate = scope.main_isolate(); | 290 Isolate* isolate = scope.main_isolate(); |
| 294 Handle<Object> result; | 291 Handle<Object> result; |
| 295 bool has_pending_exception = | 292 bool has_pending_exception = |
| 296 !Execution::Call(isolate, t.function, | 293 !Execution::Call(isolate, t.function, |
| 297 isolate->factory()->undefined_value(), 0, NULL, | 294 isolate->factory()->undefined_value(), 0, NULL, |
| 298 false).ToHandle(&result); | 295 false).ToHandle(&result); |
| 299 CHECK(!has_pending_exception); | 296 CHECK(!has_pending_exception); |
| 300 CHECK(result->SameValue(Smi::FromInt(42))); | 297 CHECK(result->SameValue(Smi::FromInt(42))); |
| 301 } | 298 } |
| 302 | 299 |
| 303 #endif | 300 #endif |
| OLD | NEW |