| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 8474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8485 Handle<Object> result = | 8485 Handle<Object> result = |
| 8486 isolate->factory()->NewTypeError("with_expression", | 8486 isolate->factory()->NewTypeError("with_expression", |
| 8487 HandleVector(&handle, 1)); | 8487 HandleVector(&handle, 1)); |
| 8488 return isolate->Throw(*result); | 8488 return isolate->Throw(*result); |
| 8489 } else { | 8489 } else { |
| 8490 return maybe_js_object; | 8490 return maybe_js_object; |
| 8491 } | 8491 } |
| 8492 } | 8492 } |
| 8493 } | 8493 } |
| 8494 | 8494 |
| 8495 JSFunction* function; | 8495 JSFunction* function = JSFunction::cast(args[1]); |
| 8496 if (args[1]->IsSmi()) { | |
| 8497 // A smi sentinel indicates a context nested inside global code rather | |
| 8498 // than some function. There is a canonical empty function that can be | |
| 8499 // gotten from the global context. | |
| 8500 function = isolate->context()->global_context()->closure(); | |
| 8501 } else { | |
| 8502 function = JSFunction::cast(args[1]); | |
| 8503 } | |
| 8504 | |
| 8505 Context* context; | 8496 Context* context; |
| 8506 MaybeObject* maybe_context = | 8497 MaybeObject* maybe_context = |
| 8507 isolate->heap()->AllocateWithContext(function, | 8498 isolate->heap()->AllocateWithContext(function, |
| 8508 isolate->context(), | 8499 isolate->context(), |
| 8509 extension_object); | 8500 extension_object); |
| 8510 if (!maybe_context->To(&context)) return maybe_context; | 8501 if (!maybe_context->To(&context)) return maybe_context; |
| 8511 isolate->set_context(context); | 8502 isolate->set_context(context); |
| 8512 return context; | 8503 return context; |
| 8513 } | 8504 } |
| 8514 | 8505 |
| 8515 | 8506 |
| 8516 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushCatchContext) { | 8507 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushCatchContext) { |
| 8517 NoHandleAllocation ha; | 8508 NoHandleAllocation ha; |
| 8518 ASSERT(args.length() == 3); | 8509 ASSERT(args.length() == 3); |
| 8519 String* name = String::cast(args[0]); | 8510 String* name = String::cast(args[0]); |
| 8520 Object* thrown_object = args[1]; | 8511 Object* thrown_object = args[1]; |
| 8521 JSFunction* function; | 8512 JSFunction* function = JSFunction::cast(args[2]); |
| 8522 if (args[2]->IsSmi()) { | |
| 8523 // A smi sentinel indicates a context nested inside global code rather | |
| 8524 // than some function. There is a canonical empty function that can be | |
| 8525 // gotten from the global context. | |
| 8526 function = isolate->context()->global_context()->closure(); | |
| 8527 } else { | |
| 8528 function = JSFunction::cast(args[2]); | |
| 8529 } | |
| 8530 Context* context; | 8513 Context* context; |
| 8531 MaybeObject* maybe_context = | 8514 MaybeObject* maybe_context = |
| 8532 isolate->heap()->AllocateCatchContext(function, | 8515 isolate->heap()->AllocateCatchContext(function, |
| 8533 isolate->context(), | 8516 isolate->context(), |
| 8534 name, | 8517 name, |
| 8535 thrown_object); | 8518 thrown_object); |
| 8536 if (!maybe_context->To(&context)) return maybe_context; | 8519 if (!maybe_context->To(&context)) return maybe_context; |
| 8537 isolate->set_context(context); | 8520 isolate->set_context(context); |
| 8538 return context; | 8521 return context; |
| 8539 } | 8522 } |
| 8540 | 8523 |
| 8541 | 8524 |
| 8542 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushBlockContext) { | 8525 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushBlockContext) { |
| 8543 NoHandleAllocation ha; | 8526 NoHandleAllocation ha; |
| 8544 ASSERT(args.length() == 2); | 8527 ASSERT(args.length() == 2); |
| 8545 SerializedScopeInfo* scope_info = SerializedScopeInfo::cast(args[0]); | 8528 SerializedScopeInfo* scope_info = SerializedScopeInfo::cast(args[0]); |
| 8546 JSFunction* function; | 8529 JSFunction* function = JSFunction::cast(args[1]); |
| 8547 if (args[1]->IsSmi()) { | |
| 8548 // A smi sentinel indicates a context nested inside global code rather | |
| 8549 // than some function. There is a canonical empty function that can be | |
| 8550 // gotten from the global context. | |
| 8551 function = isolate->context()->global_context()->closure(); | |
| 8552 } else { | |
| 8553 function = JSFunction::cast(args[1]); | |
| 8554 } | |
| 8555 Context* context; | 8530 Context* context; |
| 8556 MaybeObject* maybe_context = | 8531 MaybeObject* maybe_context = |
| 8557 isolate->heap()->AllocateBlockContext(function, | 8532 isolate->heap()->AllocateBlockContext(function, |
| 8558 isolate->context(), | 8533 isolate->context(), |
| 8559 scope_info); | 8534 scope_info); |
| 8560 if (!maybe_context->To(&context)) return maybe_context; | 8535 if (!maybe_context->To(&context)) return maybe_context; |
| 8561 isolate->set_context(context); | 8536 isolate->set_context(context); |
| 8562 return context; | 8537 return context; |
| 8563 } | 8538 } |
| 8564 | 8539 |
| (...skipping 4652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13217 } else { | 13192 } else { |
| 13218 // Handle last resort GC and make sure to allow future allocations | 13193 // Handle last resort GC and make sure to allow future allocations |
| 13219 // to grow the heap without causing GCs (if possible). | 13194 // to grow the heap without causing GCs (if possible). |
| 13220 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13195 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13221 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13196 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 13222 } | 13197 } |
| 13223 } | 13198 } |
| 13224 | 13199 |
| 13225 | 13200 |
| 13226 } } // namespace v8::internal | 13201 } } // namespace v8::internal |
| OLD | NEW |