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

Side by Side Diff: src/runtime.cc

Issue 8403036: Remove kInvalidStrictFlag and make gcc-4.5 happy again. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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/parser.h ('k') | src/stub-cache.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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 double name = args.number_at(index); 99 double name = args.number_at(index);
100 100
101 // Call the specified converter on the object *comand store the result in 101 // Call the specified converter on the object *comand store the result in
102 // a variable of the specified type with the given name. If the 102 // a variable of the specified type with the given name. If the
103 // object is not a Number call IllegalOperation and return. 103 // object is not a Number call IllegalOperation and return.
104 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ 104 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \
105 RUNTIME_ASSERT(obj->IsNumber()); \ 105 RUNTIME_ASSERT(obj->IsNumber()); \
106 type name = NumberTo##Type(obj); 106 type name = NumberTo##Type(obj);
107 107
108 108
109 // Assert that the given argument has a valid value for a StrictModeFlag
110 // and store it in a StrictModeFlag variable with the given name.
111 #define CONVERT_STRICT_MODE_ARG(name, index) \
112 ASSERT(args[index]->IsSmi()); \
113 ASSERT(args.smi_at(index) == kStrictMode || \
114 args.smi_at(index) == kNonStrictMode); \
115 StrictModeFlag name = \
116 static_cast<StrictModeFlag>(args.smi_at(index));
117
118
109 MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate, 119 MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
110 JSObject* boilerplate) { 120 JSObject* boilerplate) {
111 StackLimitCheck check(isolate); 121 StackLimitCheck check(isolate);
112 if (check.HasOverflowed()) return isolate->StackOverflow(); 122 if (check.HasOverflowed()) return isolate->StackOverflow();
113 123
114 Heap* heap = isolate->heap(); 124 Heap* heap = isolate->heap();
115 Object* result; 125 Object* result;
116 { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate); 126 { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate);
117 if (!maybe_result->ToObject(&result)) return maybe_result; 127 if (!maybe_result->ToObject(&result)) return maybe_result;
118 } 128 }
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 // args[2] == value (optional) 1518 // args[2] == value (optional)
1509 1519
1510 // Determine if we need to assign to the variable if it already 1520 // Determine if we need to assign to the variable if it already
1511 // exists (based on the number of arguments). 1521 // exists (based on the number of arguments).
1512 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); 1522 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3);
1513 bool assign = args.length() == 3; 1523 bool assign = args.length() == 3;
1514 1524
1515 CONVERT_ARG_CHECKED(String, name, 0); 1525 CONVERT_ARG_CHECKED(String, name, 0);
1516 GlobalObject* global = isolate->context()->global(); 1526 GlobalObject* global = isolate->context()->global();
1517 RUNTIME_ASSERT(args[1]->IsSmi()); 1527 RUNTIME_ASSERT(args[1]->IsSmi());
1518 StrictModeFlag strict_mode = static_cast<StrictModeFlag>(args.smi_at(1)); 1528 CONVERT_STRICT_MODE_ARG(strict_mode, 1);
1519 ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode);
1520 1529
1521 // According to ECMA-262, section 12.2, page 62, the property must 1530 // According to ECMA-262, section 12.2, page 62, the property must
1522 // not be deletable. 1531 // not be deletable.
1523 PropertyAttributes attributes = DONT_DELETE; 1532 PropertyAttributes attributes = DONT_DELETE;
1524 1533
1525 // Lookup the property locally in the global object. If it isn't 1534 // Lookup the property locally in the global object. If it isn't
1526 // there, there is a property with this name in the prototype chain. 1535 // there, there is a property with this name in the prototype chain.
1527 // We follow Safari and Firefox behavior and only set the property 1536 // We follow Safari and Firefox behavior and only set the property
1528 // locally if there is an explicit initialization value that we have 1537 // locally if there is an explicit initialization value that we have
1529 // to assign to the property. 1538 // to assign to the property.
(...skipping 3057 matching lines...) Expand 10 before | Expand all | Expand 10 after
4587 Handle<Object> value = args.at<Object>(2); 4596 Handle<Object> value = args.at<Object>(2);
4588 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); 4597 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
4589 RUNTIME_ASSERT( 4598 RUNTIME_ASSERT(
4590 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 4599 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
4591 // Compute attributes. 4600 // Compute attributes.
4592 PropertyAttributes attributes = 4601 PropertyAttributes attributes =
4593 static_cast<PropertyAttributes>(unchecked_attributes); 4602 static_cast<PropertyAttributes>(unchecked_attributes);
4594 4603
4595 StrictModeFlag strict_mode = kNonStrictMode; 4604 StrictModeFlag strict_mode = kNonStrictMode;
4596 if (args.length() == 5) { 4605 if (args.length() == 5) {
4597 CONVERT_SMI_ARG_CHECKED(strict_unchecked, 4); 4606 CONVERT_STRICT_MODE_ARG(strict_mode_flag, 4);
4598 RUNTIME_ASSERT(strict_unchecked == kStrictMode || 4607 strict_mode = strict_mode_flag;
4599 strict_unchecked == kNonStrictMode);
4600 strict_mode = static_cast<StrictModeFlag>(strict_unchecked);
4601 } 4608 }
4602 4609
4603 return Runtime::SetObjectProperty(isolate, 4610 return Runtime::SetObjectProperty(isolate,
4604 object, 4611 object,
4605 key, 4612 key,
4606 value, 4613 value,
4607 attributes, 4614 attributes,
4608 strict_mode); 4615 strict_mode);
4609 } 4616 }
4610 4617
(...skipping 4394 matching lines...) Expand 10 before | Expand all | Expand 10 after
9005 } 9012 }
9006 9013
9007 9014
9008 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) { 9015 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) {
9009 HandleScope scope(isolate); 9016 HandleScope scope(isolate);
9010 ASSERT(args.length() == 4); 9017 ASSERT(args.length() == 4);
9011 9018
9012 Handle<Object> value(args[0], isolate); 9019 Handle<Object> value(args[0], isolate);
9013 CONVERT_ARG_CHECKED(Context, context, 1); 9020 CONVERT_ARG_CHECKED(Context, context, 1);
9014 CONVERT_ARG_CHECKED(String, name, 2); 9021 CONVERT_ARG_CHECKED(String, name, 2);
9015 CONVERT_SMI_ARG_CHECKED(strict_unchecked, 3); 9022 CONVERT_STRICT_MODE_ARG(strict_mode, 3);
9016 RUNTIME_ASSERT(strict_unchecked == kStrictMode ||
9017 strict_unchecked == kNonStrictMode);
9018 StrictModeFlag strict_mode = static_cast<StrictModeFlag>(strict_unchecked);
9019 9023
9020 int index; 9024 int index;
9021 PropertyAttributes attributes; 9025 PropertyAttributes attributes;
9022 ContextLookupFlags flags = FOLLOW_CHAINS; 9026 ContextLookupFlags flags = FOLLOW_CHAINS;
9023 BindingFlags binding_flags; 9027 BindingFlags binding_flags;
9024 Handle<Object> holder = context->Lookup(name, 9028 Handle<Object> holder = context->Lookup(name,
9025 flags, 9029 flags,
9026 &index, 9030 &index,
9027 &attributes, 9031 &attributes,
9028 &binding_flags); 9032 &binding_flags);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
9481 return MakePair(*callee, *receiver); 9485 return MakePair(*callee, *receiver);
9482 } 9486 }
9483 9487
9484 // 'eval' is bound in the global context, but it may have been overwritten. 9488 // 'eval' is bound in the global context, but it may have been overwritten.
9485 // Compare it to the builtin 'GlobalEval' function to make sure. 9489 // Compare it to the builtin 'GlobalEval' function to make sure.
9486 if (*callee != isolate->global_context()->global_eval_fun() || 9490 if (*callee != isolate->global_context()->global_eval_fun() ||
9487 !args[1]->IsString()) { 9491 !args[1]->IsString()) {
9488 return MakePair(*callee, isolate->heap()->the_hole_value()); 9492 return MakePair(*callee, isolate->heap()->the_hole_value());
9489 } 9493 }
9490 9494
9491 ASSERT(args[3]->IsSmi()); 9495 CONVERT_STRICT_MODE_ARG(strict_mode, 3);
9492 return CompileGlobalEval(isolate, 9496 return CompileGlobalEval(isolate,
9493 args.at<String>(1), 9497 args.at<String>(1),
9494 args.at<Object>(2), 9498 args.at<Object>(2),
9495 static_cast<StrictModeFlag>(args.smi_at(3))); 9499 strict_mode);
9496 } 9500 }
9497 9501
9498 9502
9499 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEvalNoLookup) { 9503 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEvalNoLookup) {
9500 ASSERT(args.length() == 4); 9504 ASSERT(args.length() == 4);
9501 9505
9502 HandleScope scope(isolate); 9506 HandleScope scope(isolate);
9503 Handle<Object> callee = args.at<Object>(0); 9507 Handle<Object> callee = args.at<Object>(0);
9504 9508
9505 // 'eval' is bound in the global context, but it may have been overwritten. 9509 // 'eval' is bound in the global context, but it may have been overwritten.
9506 // Compare it to the builtin 'GlobalEval' function to make sure. 9510 // Compare it to the builtin 'GlobalEval' function to make sure.
9507 if (*callee != isolate->global_context()->global_eval_fun() || 9511 if (*callee != isolate->global_context()->global_eval_fun() ||
9508 !args[1]->IsString()) { 9512 !args[1]->IsString()) {
9509 return MakePair(*callee, isolate->heap()->the_hole_value()); 9513 return MakePair(*callee, isolate->heap()->the_hole_value());
9510 } 9514 }
9511 9515
9512 ASSERT(args[3]->IsSmi()); 9516 CONVERT_STRICT_MODE_ARG(strict_mode, 3);
9513 return CompileGlobalEval(isolate, 9517 return CompileGlobalEval(isolate,
9514 args.at<String>(1), 9518 args.at<String>(1),
9515 args.at<Object>(2), 9519 args.at<Object>(2),
9516 static_cast<StrictModeFlag>(args.smi_at(3))); 9520 strict_mode);
9517 } 9521 }
9518 9522
9519 9523
9520 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNewFunctionAttributes) { 9524 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNewFunctionAttributes) {
9521 // This utility adjusts the property attributes for newly created Function 9525 // This utility adjusts the property attributes for newly created Function
9522 // object ("new Function(...)") by changing the map. 9526 // object ("new Function(...)") by changing the map.
9523 // All it does is changing the prototype property to enumerable 9527 // All it does is changing the prototype property to enumerable
9524 // as specified in ECMA262, 15.3.5.2. 9528 // as specified in ECMA262, 15.3.5.2.
9525 HandleScope scope(isolate); 9529 HandleScope scope(isolate);
9526 ASSERT(args.length() == 1); 9530 ASSERT(args.length() == 1);
(...skipping 3999 matching lines...) Expand 10 before | Expand all | Expand 10 after
13526 } else { 13530 } else {
13527 // Handle last resort GC and make sure to allow future allocations 13531 // Handle last resort GC and make sure to allow future allocations
13528 // to grow the heap without causing GCs (if possible). 13532 // to grow the heap without causing GCs (if possible).
13529 isolate->counters()->gc_last_resort_from_js()->Increment(); 13533 isolate->counters()->gc_last_resort_from_js()->Increment();
13530 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13534 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13531 } 13535 }
13532 } 13536 }
13533 13537
13534 13538
13535 } } // namespace v8::internal 13539 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698