| 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/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
| 6 #include "src/compiler/graph.h" | 6 #include "src/compiler/graph.h" |
| 7 #include "src/compiler/js-operator.h" | 7 #include "src/compiler/js-operator.h" |
| 8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 #include "src/compiler/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 break; | 331 break; |
| 332 } | 332 } |
| 333 default: | 333 default: |
| 334 break; | 334 break; |
| 335 } | 335 } |
| 336 return MaybeHandle<Context>(); | 336 return MaybeHandle<Context>(); |
| 337 } | 337 } |
| 338 | 338 |
| 339 | 339 |
| 340 // static | 340 // static |
| 341 MaybeHandle<Context> NodeProperties::GetSpecializationNativeContext( | |
| 342 Node* node, MaybeHandle<Context> native_context) { | |
| 343 while (true) { | |
| 344 switch (node->opcode()) { | |
| 345 case IrOpcode::kJSLoadContext: { | |
| 346 ContextAccess const& access = ContextAccessOf(node->op()); | |
| 347 if (access.index() != Context::NATIVE_CONTEXT_INDEX) { | |
| 348 return MaybeHandle<Context>(); | |
| 349 } | |
| 350 // Skip over the intermediate contexts, we're only interested in the | |
| 351 // very last context in the context chain anyway. | |
| 352 node = NodeProperties::GetContextInput(node); | |
| 353 break; | |
| 354 } | |
| 355 case IrOpcode::kJSCreateBlockContext: | |
| 356 case IrOpcode::kJSCreateCatchContext: | |
| 357 case IrOpcode::kJSCreateFunctionContext: | |
| 358 case IrOpcode::kJSCreateScriptContext: | |
| 359 case IrOpcode::kJSCreateWithContext: { | |
| 360 // Skip over the intermediate contexts, we're only interested in the | |
| 361 // very last context in the context chain anyway. | |
| 362 node = NodeProperties::GetContextInput(node); | |
| 363 break; | |
| 364 } | |
| 365 case IrOpcode::kHeapConstant: { | |
| 366 // Extract the native context from the actual {context}. | |
| 367 Handle<Context> context = | |
| 368 Handle<Context>::cast(OpParameter<Handle<HeapObject>>(node)); | |
| 369 return handle(context->native_context()); | |
| 370 } | |
| 371 case IrOpcode::kOsrGuard: { | |
| 372 Node* osr_value = node->InputAt(0); | |
| 373 DCHECK_EQ(IrOpcode::kOsrValue, osr_value->opcode()); | |
| 374 int const index = OsrValueIndexOf(osr_value->op()); | |
| 375 if (index == Linkage::kOsrContextSpillSlotIndex) { | |
| 376 return native_context; | |
| 377 } | |
| 378 return MaybeHandle<Context>(); | |
| 379 } | |
| 380 case IrOpcode::kParameter: { | |
| 381 Node* const start = NodeProperties::GetValueInput(node, 0); | |
| 382 DCHECK_EQ(IrOpcode::kStart, start->opcode()); | |
| 383 int const index = ParameterIndexOf(node->op()); | |
| 384 // The context is always the last parameter to a JavaScript function, | |
| 385 // and {Parameter} indices start at -1, so value outputs of {Start} | |
| 386 // look like this: closure, receiver, param0, ..., paramN, context. | |
| 387 if (index == start->op()->ValueOutputCount() - 2) { | |
| 388 return native_context; | |
| 389 } | |
| 390 return MaybeHandle<Context>(); | |
| 391 } | |
| 392 default: | |
| 393 return MaybeHandle<Context>(); | |
| 394 } | |
| 395 } | |
| 396 } | |
| 397 | |
| 398 | |
| 399 // static | |
| 400 MaybeHandle<JSGlobalObject> NodeProperties::GetSpecializationGlobalObject( | |
| 401 Node* node, MaybeHandle<Context> native_context) { | |
| 402 Handle<Context> context; | |
| 403 if (GetSpecializationNativeContext(node, native_context).ToHandle(&context)) { | |
| 404 return handle(context->global_object()); | |
| 405 } | |
| 406 return MaybeHandle<JSGlobalObject>(); | |
| 407 } | |
| 408 | |
| 409 | |
| 410 // static | |
| 411 Type* NodeProperties::GetTypeOrAny(Node* node) { | 341 Type* NodeProperties::GetTypeOrAny(Node* node) { |
| 412 return IsTyped(node) ? node->type() : Type::Any(); | 342 return IsTyped(node) ? node->type() : Type::Any(); |
| 413 } | 343 } |
| 414 | 344 |
| 415 | 345 |
| 416 // static | 346 // static |
| 417 bool NodeProperties::AllValueInputsAreTyped(Node* node) { | 347 bool NodeProperties::AllValueInputsAreTyped(Node* node) { |
| 418 int input_count = node->op()->ValueInputCount(); | 348 int input_count = node->op()->ValueInputCount(); |
| 419 for (int index = 0; index < input_count; ++index) { | 349 for (int index = 0; index < input_count; ++index) { |
| 420 if (!IsTyped(GetValueInput(node, index))) return false; | 350 if (!IsTyped(GetValueInput(node, index))) return false; |
| 421 } | 351 } |
| 422 return true; | 352 return true; |
| 423 } | 353 } |
| 424 | 354 |
| 425 | 355 |
| 426 // static | 356 // static |
| 427 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { | 357 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { |
| 428 if (num == 0) return false; | 358 if (num == 0) return false; |
| 429 int const index = edge.index(); | 359 int const index = edge.index(); |
| 430 return first <= index && index < first + num; | 360 return first <= index && index < first + num; |
| 431 } | 361 } |
| 432 | 362 |
| 433 } // namespace compiler | 363 } // namespace compiler |
| 434 } // namespace internal | 364 } // namespace internal |
| 435 } // namespace v8 | 365 } // namespace v8 |
| OLD | NEW |