OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 HandleScope scope(isolate); | 1285 HandleScope scope(isolate); |
1286 Handle<String> name(String::cast(pairs->get(i))); | 1286 Handle<String> name(String::cast(pairs->get(i))); |
1287 Handle<Object> value(pairs->get(i + 1), isolate); | 1287 Handle<Object> value(pairs->get(i + 1), isolate); |
1288 | 1288 |
1289 // We have to declare a global const property. To capture we only | 1289 // We have to declare a global const property. To capture we only |
1290 // assign to it when evaluating the assignment for "const x = | 1290 // assign to it when evaluating the assignment for "const x = |
1291 // <expr>" the initial value is the hole. | 1291 // <expr>" the initial value is the hole. |
1292 bool is_var = value->IsUndefined(); | 1292 bool is_var = value->IsUndefined(); |
1293 bool is_const = value->IsTheHole(); | 1293 bool is_const = value->IsTheHole(); |
1294 bool is_function = value->IsSharedFunctionInfo(); | 1294 bool is_function = value->IsSharedFunctionInfo(); |
1295 bool is_module = value->IsJSObject(); | 1295 bool is_module = value->IsJSModule(); |
1296 ASSERT(is_var + is_const + is_function + is_module == 1); | 1296 ASSERT(is_var + is_const + is_function + is_module == 1); |
1297 | 1297 |
1298 if (is_var || is_const) { | 1298 if (is_var || is_const) { |
1299 // Lookup the property in the global object, and don't set the | 1299 // Lookup the property in the global object, and don't set the |
1300 // value of the variable if the property is already there. | 1300 // value of the variable if the property is already there. |
1301 // Do the lookup locally only, see ES5 errata. | 1301 // Do the lookup locally only, see ES5 errata. |
1302 LookupResult lookup(isolate); | 1302 LookupResult lookup(isolate); |
1303 global->LocalLookup(*name, &lookup); | 1303 global->LocalLookup(*name, &lookup); |
1304 if (lookup.IsProperty()) { | 1304 if (lookup.IsProperty()) { |
1305 // We found an existing property. Unless it was an interceptor | 1305 // We found an existing property. Unless it was an interceptor |
(...skipping 7285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8591 MaybeObject* maybe_context = | 8591 MaybeObject* maybe_context = |
8592 isolate->heap()->AllocateBlockContext(function, | 8592 isolate->heap()->AllocateBlockContext(function, |
8593 isolate->context(), | 8593 isolate->context(), |
8594 scope_info); | 8594 scope_info); |
8595 if (!maybe_context->To(&context)) return maybe_context; | 8595 if (!maybe_context->To(&context)) return maybe_context; |
8596 isolate->set_context(context); | 8596 isolate->set_context(context); |
8597 return context; | 8597 return context; |
8598 } | 8598 } |
8599 | 8599 |
8600 | 8600 |
| 8601 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushModuleContext) { |
| 8602 NoHandleAllocation ha; |
| 8603 ASSERT(args.length() == 2); |
| 8604 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 0); |
| 8605 CONVERT_ARG_HANDLE_CHECKED(JSModule, instance, 1); |
| 8606 |
| 8607 Context* context; |
| 8608 MaybeObject* maybe_context = |
| 8609 isolate->heap()->AllocateModuleContext(isolate->context(), |
| 8610 scope_info); |
| 8611 if (!maybe_context->To(&context)) return maybe_context; |
| 8612 // Also initialize the context slot of the instance object. |
| 8613 instance->set_context(context); |
| 8614 isolate->set_context(context); |
| 8615 |
| 8616 return context; |
| 8617 } |
| 8618 |
| 8619 |
8601 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteContextSlot) { | 8620 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteContextSlot) { |
8602 HandleScope scope(isolate); | 8621 HandleScope scope(isolate); |
8603 ASSERT(args.length() == 2); | 8622 ASSERT(args.length() == 2); |
8604 | 8623 |
8605 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 8624 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
8606 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); | 8625 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); |
8607 | 8626 |
8608 int index; | 8627 int index; |
8609 PropertyAttributes attributes; | 8628 PropertyAttributes attributes; |
8610 ContextLookupFlags flags = FOLLOW_CHAINS; | 8629 ContextLookupFlags flags = FOLLOW_CHAINS; |
(...skipping 4736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13347 // Handle last resort GC and make sure to allow future allocations | 13366 // Handle last resort GC and make sure to allow future allocations |
13348 // to grow the heap without causing GCs (if possible). | 13367 // to grow the heap without causing GCs (if possible). |
13349 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13368 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13350 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13369 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13351 "Runtime::PerformGC"); | 13370 "Runtime::PerformGC"); |
13352 } | 13371 } |
13353 } | 13372 } |
13354 | 13373 |
13355 | 13374 |
13356 } } // namespace v8::internal | 13375 } } // namespace v8::internal |
OLD | NEW |