Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: src/runtime.cc

Issue 9844002: Implement rudimentary module linking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 LookupResult lookup(isolate); 1301 LookupResult lookup(isolate);
1302 global->Lookup(*name, &lookup); 1302 global->Lookup(*name, &lookup);
1303 if (lookup.IsProperty()) { 1303 if (lookup.IsProperty()) {
1304 // We found an existing property. Unless it was an interceptor 1304 // We found an existing property. Unless it was an interceptor
1305 // that claims the property is absent, skip this declaration. 1305 // that claims the property is absent, skip this declaration.
(...skipping 7296 matching lines...) Expand 10 before | Expand all | Expand 10 after
8602 MaybeObject* maybe_context = 8602 MaybeObject* maybe_context =
8603 isolate->heap()->AllocateBlockContext(function, 8603 isolate->heap()->AllocateBlockContext(function,
8604 isolate->context(), 8604 isolate->context(),
8605 scope_info); 8605 scope_info);
8606 if (!maybe_context->To(&context)) return maybe_context; 8606 if (!maybe_context->To(&context)) return maybe_context;
8607 isolate->set_context(context); 8607 isolate->set_context(context);
8608 return context; 8608 return context;
8609 } 8609 }
8610 8610
8611 8611
8612 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushModuleContext) {
8613 NoHandleAllocation ha;
8614 ASSERT(args.length() == 2);
8615 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 0);
8616 CONVERT_ARG_HANDLE_CHECKED(JSModule, instance, 1);
8617
8618 Context* context;
8619 MaybeObject* maybe_context =
8620 isolate->heap()->AllocateModuleContext(isolate->context(),
8621 scope_info);
8622 if (!maybe_context->To(&context)) return maybe_context;
8623 // Also initialize the context slot of the instance object.
8624 instance->set_context(context);
8625 isolate->set_context(context);
8626
8627 return context;
8628 }
8629
8630
8612 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteContextSlot) { 8631 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteContextSlot) {
8613 HandleScope scope(isolate); 8632 HandleScope scope(isolate);
8614 ASSERT(args.length() == 2); 8633 ASSERT(args.length() == 2);
8615 8634
8616 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); 8635 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0);
8617 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); 8636 CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
8618 8637
8619 int index; 8638 int index;
8620 PropertyAttributes attributes; 8639 PropertyAttributes attributes;
8621 ContextLookupFlags flags = FOLLOW_CHAINS; 8640 ContextLookupFlags flags = FOLLOW_CHAINS;
(...skipping 4717 matching lines...) Expand 10 before | Expand all | Expand 10 after
13339 // Handle last resort GC and make sure to allow future allocations 13358 // Handle last resort GC and make sure to allow future allocations
13340 // to grow the heap without causing GCs (if possible). 13359 // to grow the heap without causing GCs (if possible).
13341 isolate->counters()->gc_last_resort_from_js()->Increment(); 13360 isolate->counters()->gc_last_resort_from_js()->Increment();
13342 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13361 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13343 "Runtime::PerformGC"); 13362 "Runtime::PerformGC");
13344 } 13363 }
13345 } 13364 }
13346 13365
13347 13366
13348 } } // namespace v8::internal 13367 } } // namespace v8::internal
OLDNEW
« src/heap.cc ('K') | « src/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698