| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/arm64/lithium-codegen-arm64.h" | 7 #include "src/arm64/lithium-codegen-arm64.h" |
| 8 #include "src/arm64/lithium-gap-resolver-arm64.h" | 8 #include "src/arm64/lithium-gap-resolver-arm64.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 const Heap::RootListIndex index_; | 217 const Heap::RootListIndex index_; |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 | 220 |
| 221 void LCodeGen::WriteTranslation(LEnvironment* environment, | 221 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| 222 Translation* translation) { | 222 Translation* translation) { |
| 223 if (environment == NULL) return; | 223 if (environment == NULL) return; |
| 224 | 224 |
| 225 // The translation includes one command per value in the environment. | 225 // The translation includes one command per value in the environment. |
| 226 int translation_size = environment->translation_size(); | 226 int translation_size = environment->translation_size(); |
| 227 // The output frame height does not include the parameters. | |
| 228 int height = translation_size - environment->parameter_count(); | |
| 229 | 227 |
| 230 WriteTranslation(environment->outer(), translation); | 228 WriteTranslation(environment->outer(), translation); |
| 231 | 229 WriteTranslationFrame(environment, translation); |
| 232 switch (environment->frame_type()) { | |
| 233 case JS_FUNCTION: { | |
| 234 int shared_id = DefineDeoptimizationLiteral( | |
| 235 environment->entry() ? environment->entry()->shared() | |
| 236 : info()->shared_info()); | |
| 237 translation->BeginJSFrame(environment->ast_id(), shared_id, height); | |
| 238 if (info()->closure().is_identical_to(environment->closure())) { | |
| 239 translation->StoreJSFrameFunction(); | |
| 240 } else { | |
| 241 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 242 translation->StoreLiteral(closure_id); | |
| 243 } | |
| 244 break; | |
| 245 } | |
| 246 case JS_CONSTRUCT: { | |
| 247 int shared_id = DefineDeoptimizationLiteral( | |
| 248 environment->entry() ? environment->entry()->shared() | |
| 249 : info()->shared_info()); | |
| 250 translation->BeginConstructStubFrame(shared_id, translation_size); | |
| 251 if (info()->closure().is_identical_to(environment->closure())) { | |
| 252 translation->StoreJSFrameFunction(); | |
| 253 } else { | |
| 254 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 255 translation->StoreLiteral(closure_id); | |
| 256 } | |
| 257 break; | |
| 258 } | |
| 259 case JS_GETTER: { | |
| 260 DCHECK(translation_size == 1); | |
| 261 DCHECK(height == 0); | |
| 262 int shared_id = DefineDeoptimizationLiteral( | |
| 263 environment->entry() ? environment->entry()->shared() | |
| 264 : info()->shared_info()); | |
| 265 translation->BeginGetterStubFrame(shared_id); | |
| 266 if (info()->closure().is_identical_to(environment->closure())) { | |
| 267 translation->StoreJSFrameFunction(); | |
| 268 } else { | |
| 269 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 270 translation->StoreLiteral(closure_id); | |
| 271 } | |
| 272 break; | |
| 273 } | |
| 274 case JS_SETTER: { | |
| 275 DCHECK(translation_size == 2); | |
| 276 DCHECK(height == 0); | |
| 277 int shared_id = DefineDeoptimizationLiteral( | |
| 278 environment->entry() ? environment->entry()->shared() | |
| 279 : info()->shared_info()); | |
| 280 translation->BeginSetterStubFrame(shared_id); | |
| 281 if (info()->closure().is_identical_to(environment->closure())) { | |
| 282 translation->StoreJSFrameFunction(); | |
| 283 } else { | |
| 284 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 285 translation->StoreLiteral(closure_id); | |
| 286 } | |
| 287 break; | |
| 288 } | |
| 289 case ARGUMENTS_ADAPTOR: { | |
| 290 int shared_id = DefineDeoptimizationLiteral( | |
| 291 environment->entry() ? environment->entry()->shared() | |
| 292 : info()->shared_info()); | |
| 293 translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); | |
| 294 if (info()->closure().is_identical_to(environment->closure())) { | |
| 295 translation->StoreJSFrameFunction(); | |
| 296 } else { | |
| 297 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 298 translation->StoreLiteral(closure_id); | |
| 299 } | |
| 300 break; | |
| 301 } | |
| 302 case STUB: | |
| 303 translation->BeginCompiledStubFrame(translation_size); | |
| 304 break; | |
| 305 } | |
| 306 | 230 |
| 307 int object_index = 0; | 231 int object_index = 0; |
| 308 int dematerialized_index = 0; | 232 int dematerialized_index = 0; |
| 309 for (int i = 0; i < translation_size; ++i) { | 233 for (int i = 0; i < translation_size; ++i) { |
| 310 LOperand* value = environment->values()->at(i); | 234 LOperand* value = environment->values()->at(i); |
| 311 AddToTranslation( | 235 AddToTranslation( |
| 312 environment, translation, value, environment->HasTaggedValueAt(i), | 236 environment, translation, value, environment->HasTaggedValueAt(i), |
| 313 environment->HasUint32ValueAt(i), &object_index, &dematerialized_index); | 237 environment->HasUint32ValueAt(i), &object_index, &dematerialized_index); |
| 314 } | 238 } |
| 315 } | 239 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 } else if (op->IsConstantOperand()) { | 300 } else if (op->IsConstantOperand()) { |
| 377 HConstant* constant = chunk()->LookupConstant(LConstantOperand::cast(op)); | 301 HConstant* constant = chunk()->LookupConstant(LConstantOperand::cast(op)); |
| 378 int src_index = DefineDeoptimizationLiteral(constant->handle(isolate())); | 302 int src_index = DefineDeoptimizationLiteral(constant->handle(isolate())); |
| 379 translation->StoreLiteral(src_index); | 303 translation->StoreLiteral(src_index); |
| 380 } else { | 304 } else { |
| 381 UNREACHABLE(); | 305 UNREACHABLE(); |
| 382 } | 306 } |
| 383 } | 307 } |
| 384 | 308 |
| 385 | 309 |
| 386 int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) { | |
| 387 int result = deoptimization_literals_.length(); | |
| 388 for (int i = 0; i < deoptimization_literals_.length(); ++i) { | |
| 389 if (deoptimization_literals_[i].is_identical_to(literal)) return i; | |
| 390 } | |
| 391 deoptimization_literals_.Add(literal, zone()); | |
| 392 return result; | |
| 393 } | |
| 394 | |
| 395 | |
| 396 void LCodeGen::RegisterEnvironmentForDeoptimization(LEnvironment* environment, | 310 void LCodeGen::RegisterEnvironmentForDeoptimization(LEnvironment* environment, |
| 397 Safepoint::DeoptMode mode) { | 311 Safepoint::DeoptMode mode) { |
| 398 environment->set_has_been_used(); | 312 environment->set_has_been_used(); |
| 399 if (!environment->HasBeenRegistered()) { | 313 if (!environment->HasBeenRegistered()) { |
| 400 int frame_count = 0; | 314 int frame_count = 0; |
| 401 int jsframe_count = 0; | 315 int jsframe_count = 0; |
| 402 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { | 316 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { |
| 403 ++frame_count; | 317 ++frame_count; |
| 404 if (e->frame_type() == JS_FUNCTION) { | 318 if (e->frame_type() == JS_FUNCTION) { |
| 405 ++jsframe_count; | 319 ++jsframe_count; |
| (...skipping 5727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6133 Handle<ScopeInfo> scope_info = instr->scope_info(); | 6047 Handle<ScopeInfo> scope_info = instr->scope_info(); |
| 6134 __ Push(scope_info); | 6048 __ Push(scope_info); |
| 6135 __ Push(ToRegister(instr->function())); | 6049 __ Push(ToRegister(instr->function())); |
| 6136 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6050 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 6137 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6051 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 6138 } | 6052 } |
| 6139 | 6053 |
| 6140 | 6054 |
| 6141 } // namespace internal | 6055 } // namespace internal |
| 6142 } // namespace v8 | 6056 } // namespace v8 |
| OLD | NEW |