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

Side by Side Diff: src/runtime.cc

Issue 8344082: Replace boolean indications of strict mode by an enum value. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some fixes and adapted the 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
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 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 } 1281 }
1282 1282
1283 LookupResult lookup(isolate); 1283 LookupResult lookup(isolate);
1284 global->LocalLookup(*name, &lookup); 1284 global->LocalLookup(*name, &lookup);
1285 1285
1286 // Compute the property attributes. According to ECMA-262, section 1286 // Compute the property attributes. According to ECMA-262, section
1287 // 13, page 71, the property must be read-only and 1287 // 13, page 71, the property must be read-only and
1288 // non-deletable. However, neither SpiderMonkey nor KJS creates the 1288 // non-deletable. However, neither SpiderMonkey nor KJS creates the
1289 // property as read-only, so we don't either. 1289 // property as read-only, so we don't either.
1290 int attr = NONE; 1290 int attr = NONE;
1291 if ((flags & kDeclareGlobalsEvalFlag) == 0) { 1291 if (!DeclareGlobalsEvalFlag::decode(flags)) {
1292 attr |= DONT_DELETE; 1292 attr |= DONT_DELETE;
1293 } 1293 }
1294 bool is_native = (flags & kDeclareGlobalsNativeFlag) != 0; 1294 bool is_native = DeclareGlobalsNativeFlag::decode(flags);
1295 if (is_const_property || (is_native && is_function_declaration)) { 1295 if (is_const_property || (is_native && is_function_declaration)) {
1296 attr |= READ_ONLY; 1296 attr |= READ_ONLY;
1297 } 1297 }
1298 1298
1299 // Safari does not allow the invocation of callback setters for 1299 // Safari does not allow the invocation of callback setters for
1300 // function declarations. To mimic this behavior, we do not allow 1300 // function declarations. To mimic this behavior, we do not allow
1301 // the invocation of setters for function values. This makes a 1301 // the invocation of setters for function values. This makes a
1302 // difference for global functions with the same names as event 1302 // difference for global functions with the same names as event
1303 // handlers such as "function onload() {}". Firefox does call the 1303 // handlers such as "function onload() {}". Firefox does call the
1304 // onload setter in those case and Safari does not. We follow 1304 // onload setter in those case and Safari does not. We follow
1305 // Safari for compatibility. 1305 // Safari for compatibility.
1306 if (value->IsJSFunction()) { 1306 if (value->IsJSFunction()) {
1307 // Do not change DONT_DELETE to false from true. 1307 // Do not change DONT_DELETE to false from true.
1308 if (lookup.IsProperty() && (lookup.type() != INTERCEPTOR)) { 1308 if (lookup.IsProperty() && (lookup.type() != INTERCEPTOR)) {
1309 attr |= lookup.GetAttributes() & DONT_DELETE; 1309 attr |= lookup.GetAttributes() & DONT_DELETE;
1310 } 1310 }
1311 PropertyAttributes attributes = static_cast<PropertyAttributes>(attr); 1311 PropertyAttributes attributes = static_cast<PropertyAttributes>(attr);
1312 1312
1313 RETURN_IF_EMPTY_HANDLE(isolate, 1313 RETURN_IF_EMPTY_HANDLE(isolate,
1314 SetLocalPropertyIgnoreAttributes(global, 1314 SetLocalPropertyIgnoreAttributes(global,
1315 name, 1315 name,
1316 value, 1316 value,
1317 attributes)); 1317 attributes));
1318 } else { 1318 } else {
1319 StrictModeFlag strict_mode = 1319 StrictModeFlag strict_mode = DeclareGlobalsStrictModeFlag::decode(flags);
1320 ((flags & kDeclareGlobalsStrictModeFlag) != 0) ? kStrictMode
1321 : kNonStrictMode;
1322 RETURN_IF_EMPTY_HANDLE(isolate, 1320 RETURN_IF_EMPTY_HANDLE(isolate,
1323 SetProperty(global, 1321 SetProperty(global,
1324 name, 1322 name,
1325 value, 1323 value,
1326 static_cast<PropertyAttributes>(attr), 1324 static_cast<PropertyAttributes>(attr),
1327 strict_mode)); 1325 strict_mode));
1328 } 1326 }
1329 } 1327 }
1330 1328
1331 ASSERT(!isolate->has_pending_exception()); 1329 ASSERT(!isolate->has_pending_exception());
(...skipping 12010 matching lines...) Expand 10 before | Expand all | Expand 10 after
13342 } else { 13340 } else {
13343 // Handle last resort GC and make sure to allow future allocations 13341 // Handle last resort GC and make sure to allow future allocations
13344 // to grow the heap without causing GCs (if possible). 13342 // to grow the heap without causing GCs (if possible).
13345 isolate->counters()->gc_last_resort_from_js()->Increment(); 13343 isolate->counters()->gc_last_resort_from_js()->Increment();
13346 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13344 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13347 } 13345 }
13348 } 13346 }
13349 13347
13350 13348
13351 } } // namespace v8::internal 13349 } } // namespace v8::internal
OLDNEW
« src/compiler.cc ('K') | « src/runtime.h ('k') | src/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698