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

Side by Side Diff: src/runtime.cc

Issue 7992005: Block scoped const variables. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments, function variable mode, preparser. Created 9 years, 2 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
« no previous file with comments | « src/preparser.cc ('k') | src/scopeinfo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8841 matching lines...) Expand 10 before | Expand all | Expand 10 after
8852 ASSERT(holder->IsContext()); 8852 ASSERT(holder->IsContext());
8853 // If the "property" we were looking for is a local variable, the 8853 // If the "property" we were looking for is a local variable, the
8854 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3. 8854 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3.
8855 // 8855 //
8856 // Use the hole as the receiver to signal that the receiver is implicit 8856 // Use the hole as the receiver to signal that the receiver is implicit
8857 // and that the global receiver should be used (as distinguished from an 8857 // and that the global receiver should be used (as distinguished from an
8858 // explicit receiver that happens to be a global object). 8858 // explicit receiver that happens to be a global object).
8859 Handle<Object> receiver = isolate->factory()->the_hole_value(); 8859 Handle<Object> receiver = isolate->factory()->the_hole_value();
8860 Object* value = Context::cast(*holder)->get(index); 8860 Object* value = Context::cast(*holder)->get(index);
8861 // Check for uninitialized bindings. 8861 // Check for uninitialized bindings.
8862 if (binding_flags == MUTABLE_CHECK_INITIALIZED && value->IsTheHole()) { 8862 switch (binding_flags) {
8863 Handle<Object> reference_error = 8863 case MUTABLE_CHECK_INITIALIZED:
8864 isolate->factory()->NewReferenceError("not_defined", 8864 case IMMUTABLE_CHECK_INITIALIZED_HARMONY:
8865 HandleVector(&name, 1)); 8865 if (value->IsTheHole()) {
8866 return MakePair(isolate->Throw(*reference_error), NULL); 8866 Handle<Object> reference_error =
8867 } else { 8867 isolate->factory()->NewReferenceError("not_defined",
8868 return MakePair(Unhole(isolate->heap(), value, attributes), *receiver); 8868 HandleVector(&name, 1));
8869 return MakePair(isolate->Throw(*reference_error), NULL);
8870 }
8871 // FALLTHROUGH
8872 case MUTABLE_IS_INITIALIZED:
8873 case IMMUTABLE_IS_INITIALIZED:
8874 case IMMUTABLE_IS_INITIALIZED_HARMONY:
8875 ASSERT(!value->IsTheHole());
8876 return MakePair(value, *receiver);
8877 case IMMUTABLE_CHECK_INITIALIZED:
8878 return MakePair(Unhole(isolate->heap(), value, attributes), *receiver);
8879 case MISSING_BINDING:
8880 UNREACHABLE();
8881 return MakePair(NULL, NULL);
8869 } 8882 }
8870 } 8883 }
8871 8884
8872 // Otherwise, if the slot was found the holder is a context extension 8885 // Otherwise, if the slot was found the holder is a context extension
8873 // object, subject of a with, or a global object. We read the named 8886 // object, subject of a with, or a global object. We read the named
8874 // property from it. 8887 // property from it.
8875 if (!holder.is_null()) { 8888 if (!holder.is_null()) {
8876 Handle<JSObject> object = Handle<JSObject>::cast(holder); 8889 Handle<JSObject> object = Handle<JSObject>::cast(holder);
8877 ASSERT(object->HasProperty(*name)); 8890 ASSERT(object->HasProperty(*name));
8878 // GetProperty below can cause GC. 8891 // GetProperty below can cause GC.
(...skipping 4536 matching lines...) Expand 10 before | Expand all | Expand 10 after
13415 } else { 13428 } else {
13416 // Handle last resort GC and make sure to allow future allocations 13429 // Handle last resort GC and make sure to allow future allocations
13417 // to grow the heap without causing GCs (if possible). 13430 // to grow the heap without causing GCs (if possible).
13418 isolate->counters()->gc_last_resort_from_js()->Increment(); 13431 isolate->counters()->gc_last_resort_from_js()->Increment();
13419 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13432 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13420 } 13433 }
13421 } 13434 }
13422 13435
13423 13436
13424 } } // namespace v8::internal 13437 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698